长安链源码分析共识机制 1
作者:李
- 2022-10-31 湖南
本文字数:692 字
阅读完需:约 2 分钟
本文已参与「开源摘星计划」,欢迎正在阅读的你加入。活动链接:https://github.com/weopenprojects/WeOpen-Star
共识引擎接口 ConsensusEngine 源码分析:
// ConsensusEngine consensus abstract engine//共识引擎模块接口type ConsensusEngine interface { // Start the consensus engine. //启动 Start() error // Stop stops the consensus engine. //停止 Stop() error}
// ConsensusState get consensus state//共识状态接口type ConsensusState interface { //获取所有验证者 GetValidators() ([]string, error) //获取最后高度 GetLastHeight() uint64 //获取共识状态 GetConsensusStateJSON() ([]byte, error)}
// ConsensusExtendEngine extend engine for consensus//共识扩展引擎type ConsensusExtendEngine interface { ConsensusEngine //初始化扩展handler InitExtendHandler(handler ConsensusExtendHandler)}
//ConsensusExtendHandler extend consensus handler//共识扩展处理器type ConsensusExtendHandler interface { // CreateRWSet Creates a RwSet for the proposed block //创建一个读写集为投票的区块 CreateRWSet(preBlkHash []byte, proposedBlock *consensuspb.ProposalBlock) error // VerifyConsensusArgs Verify the contents of the DPoS RwSet contained within the block //验证共识参数 VerifyConsensusArgs(block *common.Block, blockTxRwSet map[string]*common.TxRWSet) error // GetValidators Gets the validators for the current epoch //获取当前投票轮次的验证者 GetValidators() ([]string, error)}
复制代码
划线
评论
复制
发布于: 刚刚阅读数: 3
李
关注
还未添加个人签名 2018-05-04 加入
还未添加个人简介









评论