mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-05-13 03:26:38 +00:00
core: remove duplicate chainHeadFeed.Send code (#33563)
The code was simply duplicate, so we can remove some code lines here. Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
7cd400612f
commit
127d1f42bb
1 changed files with 7 additions and 16 deletions
|
|
@ -746,21 +746,7 @@ func (bc *BlockChain) SetHead(head uint64) error {
|
||||||
if _, err := bc.setHeadBeyondRoot(head, 0, common.Hash{}, false); err != nil {
|
if _, err := bc.setHeadBeyondRoot(head, 0, common.Hash{}, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Send chain head event to update the transaction pool
|
return bc.sendChainHeadEvent()
|
||||||
header := bc.CurrentBlock()
|
|
||||||
if block := bc.GetBlock(header.Hash(), header.Number.Uint64()); block == nil {
|
|
||||||
// In a pruned node the genesis block will not exist in the freezer.
|
|
||||||
// It should not happen that we set head to any other pruned block.
|
|
||||||
if header.Number.Uint64() > 0 {
|
|
||||||
// This should never happen. In practice, previously currentBlock
|
|
||||||
// contained the entire block whereas now only a "marker", so there
|
|
||||||
// is an ever so slight chance for a race we should handle.
|
|
||||||
log.Error("Current block not found in database", "block", header.Number, "hash", header.Hash())
|
|
||||||
return fmt.Errorf("current block missing: #%d [%x..]", header.Number, header.Hash().Bytes()[:4])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bc.chainHeadFeed.Send(ChainHeadEvent{Header: header})
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetHeadWithTimestamp rewinds the local chain to a new head that has at max
|
// SetHeadWithTimestamp rewinds the local chain to a new head that has at max
|
||||||
|
|
@ -771,7 +757,12 @@ func (bc *BlockChain) SetHeadWithTimestamp(timestamp uint64) error {
|
||||||
if _, err := bc.setHeadBeyondRoot(0, timestamp, common.Hash{}, false); err != nil {
|
if _, err := bc.setHeadBeyondRoot(0, timestamp, common.Hash{}, false); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Send chain head event to update the transaction pool
|
return bc.sendChainHeadEvent()
|
||||||
|
}
|
||||||
|
|
||||||
|
// sendChainHeadEvent notifies all subscribers about the new chain head,
|
||||||
|
// checking first that the current block is actually available.
|
||||||
|
func (bc *BlockChain) sendChainHeadEvent() error {
|
||||||
header := bc.CurrentBlock()
|
header := bc.CurrentBlock()
|
||||||
if block := bc.GetBlock(header.Hash(), header.Number.Uint64()); block == nil {
|
if block := bc.GetBlock(header.Hash(), header.Number.Uint64()); block == nil {
|
||||||
// In a pruned node the genesis block will not exist in the freezer.
|
// In a pruned node the genesis block will not exist in the freezer.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue