兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析.docx

兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析.docx

ID:27452634

大小:32.25 KB

页数:16页

时间:2018-12-03

兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析.docx_第1页
兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析.docx_第2页
兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析.docx_第3页
兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析.docx_第4页
兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析.docx_第5页
资源描述:

《兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析.docx》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、兄弟连Go语言+区块链技术培训以太坊源码分析(35)eth-fetcher源码分析fetcher包含基于块通知的同步。当我们接收到NewBlockHashesMsg消息得时候,我们只收到了很多Block的hash值。需要通过hash值来同步区块,然后更新本地区块链。fetcher就提供了这样的功能。数据结构    //announceisthehashnotificationoftheavailabilityofanewblockinthe    //network.    //announce是一个hash通知,表示网络上有合适的新区块出现。    typeannouncestruct{ 

2、       hashcommon.Hash//Hashoftheblockbeingannounced//新区块的hash值        numberuint64//Numberoftheblockbeingannounced(0=unknown

3、oldprotocol)区块的高度值,        header*types.Header//Headeroftheblockpartiallyreassembled(newprotocol)    重新组装的区块头        timetime.Time//Timestampoftheannouncement            ori

4、ginstring//Identifierofthepeeroriginatingthenotification            fetchHeaderheaderRequesterFn//Fetcherfunctiontoretrievetheheaderofanannouncedblock获取区块头的函数指针,里面包含了peer的信息。就是说找谁要这个区块头        fetchBodiesbodyRequesterFn//Fetcherfunctiontoretrievethebodyofanannouncedblock获取区块体的函数指针    }        //hea

5、derFilterTaskrepresentsabatchofheadersneedingfetcherfiltering.    typeheaderFilterTaskstruct{        peerstring//Thesourcepeerofblockheaders        headers[]*types.Header//Collectionofheaderstofilter        timetime.Time//Arrivaltimeoftheheaders    }        //headerFilterTaskrepresentsabatchofblock

6、bodies(transactionsanduncles)    //needingfetcherfiltering.    typebodyFilterTaskstruct{        peerstring//Thesourcepeerofblockbodies        transactions[][]*types.Transaction//Collectionoftransactionsperblockbodies        uncles[][]*types.Header//Collectionofunclesperblockbodies        timetime.T

7、ime//Arrivaltimeoftheblocks'contents    }        //injectrepresentsaschedulesimportoperation.    //当节点收到NewBlockMsg的消息时候,会插入一个区块    typeinjectstruct{        originstring        block*types.Block    }        //Fetcherisresponsibleforaccumulatingblockannouncementsfromvariouspeers    //andschedulingth

8、emforretrieval.    typeFetcherstruct{        //Variouseventchannels        notifychan*announce   //announce的通道,        injectchan*inject     //inject的通道            blockFilterchanchan[]*types.Block   //通道的通

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。