美文网首页区块链
tendermint源码阅读(八)

tendermint源码阅读(八)

作者: 印随2018 | 来源:发表于2018-11-08 22:11 被阅读43次
关注点:fastsync

这次说的内容很简单,直接看代码吧

tendermint/v0.26.0/node/node.go#L243,L251

    // Decide whether to fast-sync or not
    // We don't fast-sync when the only validator is us.
    fastSync := config.FastSync
    if state.Validators.Size() == 1 {
        addr, _ := state.Validators.GetByIndex(0)
        if bytes.Equal(privValidator.GetAddress(), addr) {
            fastSync = false
        }
    }

如果区块链中只有一个validator,并且还是节点自身,fastSync配置会强制设置为false。因为设置成ture没有任何意义,其他节点不可能出现比validator高度更高的块。

另外一个更重要的原因是,validator必须对同步的数据进行检查。这种情况出现在,当validator转移到一个新节点的时候。

相关文章

网友评论

    本文标题:tendermint源码阅读(八)

    本文链接:https://www.haomeiwen.com/subject/empgxqtx.html