`

eth_fetch

 
阅读更多
fetch的流程
1.当我们接收到NewBlockHashesMsg消息得时候,我们只收到了很多Block的hash值。 需要通过hash值来同步区块,然后更新本地区块链。 fetcher就提供了这样的功能
2.fetcher通过四个map(announced,fetching,fetched,completing )记录了announce的状态(等待fetch,正在fetch,fetch完头等待fetch body, fetch完成),并通过定时器和各种消息来对各种map里面的announce进行状态转换,announced --fetchTimer(fetch header)---> fetching --(headerFilter)--> fetched --completeTimer(fetch body)-->completing --(bodyFilter)--> enqueue --task.done--> forgetHash
3.在接收到NewBlockHashesMsg的时候,对于本地区块链还没有的区块的hash值会调用fetcher的Notify方法发送到notify通道
4.在接收到NewBlockMsg的时候会调用fetcher的Enqueue方法,这个方法会把当前接收到的区块发送到inject通道
5.header和body都收到并验证通过后,会马上广播出去
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics