diff --git a/core/blockchain.go b/core/blockchain.go index a450245e94..937d82d9db 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -582,7 +582,10 @@ func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis // Open trie database with provided config triedb := bc.triedb - chainConfig, _, genesisErr := SetupGenesisBlockWithOverride(db, triedb, genesis, overrides) + chainConfig, _, _, genesisErr := SetupGenesisBlockWithOverride(db, triedb, genesis, overrides) + if err != nil { + return nil, err + } if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok { return nil, genesisErr @@ -622,7 +625,7 @@ func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (_ usedGas uint64 err error statedb *state.StateDB - counter metrics.Counter + counter *metrics.Counter parallel bool } @@ -1557,7 +1560,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ if first.NumberU64() == 1 { if frozen, _ := bc.db.Ancients(); frozen == 0 { td := bc.genesisBlock.Difficulty() - writeSize, err := rawdb.WriteAncientBlocks(bc.db, []*types.Block{bc.genesisBlock}, []types.Receipts{nil}, td) + writeSize, err := rawdb.WriteAncientBlocks(bc.db, []*types.Block{bc.genesisBlock}, []types.Receipts{nil}, []types.Receipts{nil}, td) if err != nil { log.Error("Error writing genesis to ancients", "err", err) return 0, err @@ -1588,7 +1591,7 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [ // Write all chain data to ancients. td := bc.GetTd(first.Hash(), first.NumberU64()) - writeSize, err := rawdb.WriteAncientBlocks(bc.db, blockChain, receiptChain, td) + writeSize, err := rawdb.WriteAncientBlocks(bc.db, blockChain, receiptChain, borReceipts, td) if err != nil { log.Error("Error importing chain data to ancients", "err", err) return 0, err @@ -1821,7 +1824,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. // Calculate the total difficulty of the block ptd := bc.GetTd(block.ParentHash(), block.NumberU64()-1) if ptd == nil { - return consensus.ErrUnknownAncestor + return []*types.Log{}, consensus.ErrUnknownAncestor } // Make sure no inconsistent state is leaked during insertion externTd := new(big.Int).Add(block.Difficulty(), ptd) diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index 692c306c47..a96e891048 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -488,6 +488,11 @@ func (bc *BlockChain) SubscribeChainHeadEvent(ch chan<- ChainHeadEvent) event.Su return bc.scope.Track(bc.chainHeadFeed.Subscribe(ch)) } +// SubscribeChainSideEvent registers a subscription of ChainSideEvent. +func (bc *BlockChain) SubscribeChainSideEvent(ch chan<- ChainSideEvent) event.Subscription { + return bc.scope.Track(bc.chainSideFeed.Subscribe(ch)) +} + // SubscribeLogsEvent registers a subscription of []*types.Log. func (bc *BlockChain) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription { return bc.scope.Track(bc.logsFeed.Subscribe(ch))