mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core, core/rawdb: optimize transaction indexing
In comparison to the original code snippet, my proposed solution adjusts the indexing target to head+1 instead of *tail. This ensures that the transactions are indexed from block 0 to the current head, excluding the head block itself. This could be a more effective adjustment, includeing all the required blocks.
This commit is contained in:
parent
f1794ba278
commit
9a1bc9b4a9
1 changed files with 1 additions and 8 deletions
|
|
@ -2446,14 +2446,7 @@ func (bc *BlockChain) indexBlocks(tail *uint64, head uint64, done chan struct{})
|
||||||
// The tail flag is existent, but the whole chain is required to be indexed.
|
// The tail flag is existent, but the whole chain is required to be indexed.
|
||||||
if bc.txLookupLimit == 0 || head < bc.txLookupLimit {
|
if bc.txLookupLimit == 0 || head < bc.txLookupLimit {
|
||||||
if *tail > 0 {
|
if *tail > 0 {
|
||||||
// It can happen when chain is rewound to a historical point which
|
rawdb.IndexTransactions(bc.db, 0, head+1, bc.quit) // Adjust indexing target to head+1
|
||||||
// is even lower than the indexes tail, recap the indexing target
|
|
||||||
// to new head to avoid reading non-existent block bodies.
|
|
||||||
end := *tail
|
|
||||||
if end > head+1 {
|
|
||||||
end = head + 1
|
|
||||||
}
|
|
||||||
rawdb.IndexTransactions(bc.db, 0, end, bc.quit)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue