mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core: reset tx lookup cache if necessary
This commit is contained in:
parent
6b0de79935
commit
7b97c59f2f
1 changed files with 9 additions and 3 deletions
|
|
@ -2202,11 +2202,17 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error {
|
|||
|
||||
// Delete useless indexes right now which includes the non-canonical
|
||||
// transaction indexes, canonical chain indexes which above the head.
|
||||
indexesBatch := bc.db.NewBatch()
|
||||
for _, tx := range types.HashDifference(deletedTxs, addedTxs) {
|
||||
var (
|
||||
indexesBatch = bc.db.NewBatch()
|
||||
diffs = types.HashDifference(deletedTxs, addedTxs)
|
||||
)
|
||||
for _, tx := range diffs {
|
||||
rawdb.DeleteTxLookupEntry(indexesBatch, tx)
|
||||
}
|
||||
|
||||
// Reset the tx lookup cache in case some indexes are removed.
|
||||
if len(diffs) > 0 {
|
||||
bc.txLookupCache.Purge()
|
||||
}
|
||||
// Delete all hash markers that are not part of the new canonical chain.
|
||||
// Because the reorg function does not handle new chain head, all hash
|
||||
// markers greater than or equal to new chain head should be deleted.
|
||||
|
|
|
|||
Loading…
Reference in a new issue