diff --git a/core/blockchain.go b/core/blockchain.go index 309407fbf..b4b550476 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -531,7 +531,7 @@ func (bc *BlockChain) SetHead(head uint64) error { return err } // Send chain head event to update the transaction pool - bc.chainHeadFeed.Send(ChainHeadEvent{Block: bc.CurrentBlock()}) + bc.chainHeadFeed.Send(ChainHeadEvent{Header: bc.CurrentHeader()}) return nil } @@ -544,7 +544,7 @@ func (bc *BlockChain) SetHeadWithTimestamp(timestamp uint64) error { return err } // Send chain head event to update the transaction pool - bc.chainHeadFeed.Send(ChainHeadEvent{Block: bc.CurrentBlock()}) + bc.chainHeadFeed.Send(ChainHeadEvent{Header: bc.CurrentHeader()}) return nil } @@ -1465,7 +1465,7 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types. // we will fire an accumulated ChainHeadEvent and disable fire // event here. if emitHeadEvent { - bc.chainHeadFeed.Send(ChainHeadEvent{Block: block}) + bc.chainHeadFeed.Send(ChainHeadEvent{Header: block.Header()}) } } else { bc.chainSideFeed.Send(ChainSideEvent{Header: block.Header()}) @@ -1565,7 +1565,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er // Fire a single chain head event if we've progressed the chain defer func() { if lastCanon != nil && bc.CurrentBlock().Hash() == lastCanon.Hash() { - bc.chainHeadFeed.Send(ChainHeadEvent{lastCanon}) + bc.chainHeadFeed.Send(ChainHeadEvent{lastCanon.Header()}) } }() // Start the parallel header verifier @@ -2355,7 +2355,7 @@ func (bc *BlockChain) maintainTxIndex() { case head := <-headCh: if done == nil { done = make(chan struct{}) - go bc.indexBlocks(rawdb.ReadTxIndexTail(bc.db), head.Block.NumberU64(), done) + go bc.indexBlocks(rawdb.ReadTxIndexTail(bc.db), head.Header.Number.Uint64(), done) } case <-done: done = nil diff --git a/core/chain_indexer.go b/core/chain_indexer.go index 52938b4d3..cb6957d31 100644 --- a/core/chain_indexer.go +++ b/core/chain_indexer.go @@ -218,7 +218,7 @@ func (c *ChainIndexer) eventLoop(currentHeader *types.Header, events chan ChainH errc <- nil return } - header := ev.Block.Header() + header := ev.Header if header.ParentHash != prevHash { // Reorg to the common ancestor if needed (might not exist in light sync mode, skip reorg then) diff --git a/core/events.go b/core/events.go index 11e6de193..ae481817f 100644 --- a/core/events.go +++ b/core/events.go @@ -45,4 +45,4 @@ type ChainSideEvent struct { Header *types.Header } -type ChainHeadEvent struct{ Block *types.Block } +type ChainHeadEvent struct{ Header *types.Header } diff --git a/core/txpool/txpool.go b/core/txpool/txpool.go index 741ae048b..10502f3ab 100644 --- a/core/txpool/txpool.go +++ b/core/txpool/txpool.go @@ -332,7 +332,7 @@ func NewTxPool(config Config, chainconfig *params.ChainConfig, chain blockChain) // Subscribe events from blockchain and start the main event loop. pool.chainHeadSub = pool.chain.SubscribeChainHeadEvent(pool.chainHeadCh) - head := chain.CurrentBlock() + head := chain.CurrentBlock().Header() pool.wg.Add(1) go pool.loop(head) @@ -342,7 +342,7 @@ func NewTxPool(config Config, chainconfig *params.ChainConfig, chain blockChain) // loop is the transaction pool's main event loop, waiting for and reacting to // outside blockchain events as well as for various reporting and transaction // eviction events. -func (pool *TxPool) loop(head *types.Block) { +func (pool *TxPool) loop(head *types.Header) { defer pool.wg.Done() var ( @@ -362,9 +362,9 @@ func (pool *TxPool) loop(head *types.Block) { select { // Handle ChainHeadEvent case ev := <-pool.chainHeadCh: - if ev.Block != nil { - pool.requestReset(head.Header(), ev.Block.Header()) - head = ev.Block + if ev.Header != nil { + pool.requestReset(head, ev.Header) + head = ev.Header } // System shutdown. diff --git a/miner/worker.go b/miner/worker.go index 3d4686c9b..083468d62 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -413,7 +413,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) { commit(false, commitInterruptNewHead) case head := <-w.chainHeadCh: - clearPending(head.Block.NumberU64()) + clearPending(head.Header.Number.Uint64()) timestamp = time.Now().Unix() commit(false, commitInterruptNewHead)