长安链源码分析同步服务器 1
作者:李
- 2022-10-31 湖南
本文字数:972 字
阅读完需:约 3 分钟
本文已参与「开源摘星计划」,欢迎正在阅读的你加入。活动链接:https://github.com/weopenprojects/WeOpen-Star
区块链同步服务器结构体源码分析
//BlockChainSyncServer Service for synchronizing blocks//区块链同步服务器type BlockChainSyncServer struct { //链id chainId string // receive/broadcast messages from net module //网络模块,接收和广播消息 net protocol.NetService // receive/broadcast messages from internal modules //消息模块,接收和广播消息 msgBus msgbus.MessageBus // The module that provides blocks storage/query //区块链存储器,提供存储和查询功能 blockChainStore protocol.BlockchainStore // Provides the latest chain state for the node //账本缓存 提供节点最近的链状态 ledgerCache protocol.LedgerCache // Verify Block Validity //验证区块有效性 blockVerifier protocol.BlockVerifier // Adds a validated block to the chain to update the state of the chain //添加一个有效的区块到链,更新链的状态 blockCommitter protocol.BlockCommitter //日志 log protocol.Logger // The configuration in sync module //同步模块配置 conf *BlockSyncServerConf // Identification of module startup //启动标志 start int32 // Identification of module close //关闭通道标志 close chan bool // Service that get blocks from other nodes //从其他节点获取区块 scheduler *Routine // Service that processes block data, adding valid blocks to the chain //处理区块数据,添加有效区块到链 processor *Routine // ignore repeat block sync request when in process //忽视重复的区块同步请求 requestCache sync.Map //If the synced block height reaches the conf.minLabValue put a event to this channel //如果同步区块高度达到了最小的值,会发送一个事件到这个通道 minLagReachC chan struct{} //if a synced block is committed to local ledger put a event to this channel //如果同步区块被提交到了本地账本,会发送一个事件到这个通道 commitBlockC chan struct{}}复制代码
划线
评论
复制
发布于: 刚刚阅读数: 3
李
关注
还未添加个人签名 2018-05-04 加入
还未添加个人简介









评论