区块链中文技术社区

cdk-data-availability之TrackSequence参数分析

https://github.com/0xPolygon/cdk-data-availability/blob/e17fe08a81dee451636cadce04e568563d992d38/sequencer/tracker.go#L84-L113

// Start starts the SequencerTracker
func (st *Tracker) Start(parentCtx context.Context) {
    st.startOnce.Do(func() {
        ctx, cancel := context.WithTimeout(parentCtx, st.timeout)
        defer cancel()

        addr, err := st.em.TrustedSequencer(ctx)
        if err != nil {
            log.Fatalf("failed to get sequencer addr: %v", err)
            return
        }

        log.Infof("current sequencer addr: %s", addr.Hex())
        st.setAddr(addr)

        url, err := st.em.TrustedSequencerURL(ctx)
        if err != nil {
            log.Fatalf("failed to get sequencer addr: %v", err)
            return
        }

        log.Infof("current sequencer url: %s", url)
        st.setUrl(url)

        if st.trackChanges {
            log.Info("sequencer tracking enabled")

            go st.trackAddrChanges(parentCtx)
            go st.trackUrlChanges(parentCtx)
        }
    })
}

分析

当TrackSequence设置为true时,会在TrackSequencerPollInterval间隔内,检查L1合约内的TrustedSequencer地址和URL是否有变更,并更新本地

场景

因为TrustedSequencer地址和URL变更频率很低,默认情况下TrackSequence可以设置为false,对比变更比较频繁的场景,可以将TrackSequence改为true
注:当cdk-data-availability服务重启时,会自动对齐配置

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »