From 817e261fabe860942406eea8959bdff2f45f663c Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Thu, 14 Mar 2024 08:58:51 -0400 Subject: [PATCH] Call `OnBlockchainInit` before `OnGenesisBlock` (#22) --- core/blockchain.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 70ccce50c85b..8ccfc993e50d 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -424,6 +424,10 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis } } + if bc.logger != nil && bc.logger.OnBlockchainInit != nil { + bc.logger.OnBlockchainInit(chainConfig) + } + if bc.logger != nil && bc.logger.OnGenesisBlock != nil { if block := bc.CurrentBlock(); block.Number.Uint64() == 0 { alloc, err := getGenesisState(bc.db, block.Hash()) @@ -470,9 +474,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis } rawdb.WriteChainConfig(db, genesisHash, chainConfig) } - if bc.logger != nil && bc.logger.OnBlockchainInit != nil { - bc.logger.OnBlockchainInit(chainConfig) - } + // Start tx indexer if it's enabled. if txLookupLimit != nil { bc.txIndexer = newTxIndexer(*txLookupLimit, bc)