core/rawdb: fix iterator error handling in findTxInBlockBody

This commit is contained in:
Felix Lange 2026-02-11 14:09:59 +01:00
parent 30656d714e
commit e44cf33890

View file

@ -147,9 +147,6 @@ func findTxInBlockBody(blockbody rlp.RawValue, target common.Hash) (*types.Trans
} }
txIndex := uint64(0) txIndex := uint64(0)
for iter.Next() { for iter.Next() {
if iter.Err() != nil {
return nil, 0, iter.Err()
}
// The preimage for the hash calculation of legacy transactions // The preimage for the hash calculation of legacy transactions
// is just their RLP encoding. For typed (EIP-2718) transactions, // is just their RLP encoding. For typed (EIP-2718) transactions,
// which are encoded as byte arrays, the preimage is the content of // which are encoded as byte arrays, the preimage is the content of
@ -171,6 +168,9 @@ func findTxInBlockBody(blockbody rlp.RawValue, target common.Hash) (*types.Trans
} }
txIndex++ txIndex++
} }
if iter.Err() != nil {
return nil, 0, iter.Err()
}
return nil, 0, errors.New("transaction not found") return nil, 0, errors.New("transaction not found")
} }