Skip to content

Commit

Permalink
Merge pull request ethereum#30 from lochjin/v1.12.0-qng
Browse files Browse the repository at this point in the history
core/txpool: handle missing head in reset
  • Loading branch information
dindinw authored Jul 6, 2023
2 parents 9e83ad1 + 8a933a5 commit 9e2eef8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,14 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
"old", oldHead.Hash(), "oldnum", oldNum, "new", newHead.Hash(), "newnum", newNum)
// We still need to update the current state s.th. the lost transactions can be readded by the user
} else {
if add == nil {
// if the new head is nil, it means that something happened between
// the firing of newhead-event and _now_: most likely a
// reorg caused by sync-reversion or explicit sethead back to an
// earlier block.
log.Warn("New head missing in txpool reset", "number", newHead.Number, "hash", newHead.Hash())
return
}
for rem.NumberU64() > add.NumberU64() {
discarded = append(discarded, rem.Transactions()...)
if rem = pool.chain.GetBlock(rem.ParentHash(), rem.NumberU64()-1); rem == nil {
Expand Down

0 comments on commit 9e2eef8

Please sign in to comment.