core/txpool/legacypool: narrow down the scope of the variable (#27471)

Variables discarded, included can be defined closer to their usage.

Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
hero5512 2023-06-19 17:30:39 -04:00 committed by GitHub
parent ceca4578ca
commit 9a167c45d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1262,7 +1262,6 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
log.Debug("Skipping deep transaction reorg", "depth", depth) log.Debug("Skipping deep transaction reorg", "depth", depth)
} else { } else {
// Reorg seems shallow enough to pull in all transactions into memory // Reorg seems shallow enough to pull in all transactions into memory
var discarded, included types.Transactions
var ( var (
rem = pool.chain.GetBlock(oldHead.Hash(), oldHead.Number.Uint64()) rem = pool.chain.GetBlock(oldHead.Hash(), oldHead.Number.Uint64())
add = pool.chain.GetBlock(newHead.Hash(), newHead.Number.Uint64()) add = pool.chain.GetBlock(newHead.Hash(), newHead.Number.Uint64())
@ -1291,6 +1290,7 @@ func (pool *LegacyPool) reset(oldHead, newHead *types.Header) {
log.Warn("New head missing in txpool reset", "number", newHead.Number, "hash", newHead.Hash()) log.Warn("New head missing in txpool reset", "number", newHead.Number, "hash", newHead.Hash())
return return
} }
var discarded, included types.Transactions
for rem.NumberU64() > add.NumberU64() { for rem.NumberU64() > add.NumberU64() {
discarded = append(discarded, rem.Transactions()...) discarded = append(discarded, rem.Transactions()...)
if rem = pool.chain.GetBlock(rem.ParentHash(), rem.NumberU64()-1); rem == nil { if rem = pool.chain.GetBlock(rem.ParentHash(), rem.NumberU64()-1); rem == nil {