前面幾節(jié)都在分析以太坊的通信協(xié)議,怎么廣播,怎么同步,怎么下載。這一節(jié)講講以太坊的核心模塊BlockChain,也就是以太坊的區(qū)塊鏈。
一,BlockChain的初始化
Ethereum服務(wù)初始化func init() 的時(shí)候會(huì)調(diào)用core.SetupGenesisBlock來(lái)加載創(chuàng)始區(qū)塊。顧名思義,創(chuàng)始區(qū)塊就是以太坊區(qū)塊鏈中的第一個(gè)區(qū)塊,number值為0。緊接著調(diào)用文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-473812.html
stack, backend := makeFullNode(ctx) utils.RegisterEthService(stack, &cfg.Eth)
backend, err := eth.New(stack, cfg)
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit)
來(lái)加載以太坊的區(qū)塊鏈。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-473812.html
// NewBlockChain returns a fully initialised block chain using information
// available in the database. It initialises the default Ethereum Validator
// and Processor. NewBlockChain使用數(shù)據(jù)庫(kù)中可用的信息返回完全初始化的區(qū)塊鏈。它初始化默認(rèn)的以太坊驗(yàn)證器和處理器。
func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine,
到了這里,關(guān)于【區(qū)塊鏈 | 智能合約】Ethereum源代碼(11)- 以太坊核心BlockChain源碼分析的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!