mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
core: generate indices if txIndexTail is not nil
This commit is contained in:
parent
574454248c
commit
2d14844470
2 changed files with 11 additions and 1 deletions
|
|
@ -69,6 +69,7 @@ It expects the genesis file as argument.`,
|
|||
utils.GCModeFlag,
|
||||
utils.CacheDatabaseFlag,
|
||||
utils.CacheGCFlag,
|
||||
utils.TxLookupLimitFlag,
|
||||
},
|
||||
Category: "BLOCKCHAIN COMMANDS",
|
||||
Description: `
|
||||
|
|
@ -136,6 +137,7 @@ The export-preimages command export hash preimages to an RLP encoded stream`,
|
|||
utils.FakePoWFlag,
|
||||
utils.TestnetFlag,
|
||||
utils.RinkebyFlag,
|
||||
utils.TxLookupLimitFlag,
|
||||
},
|
||||
Category: "BLOCKCHAIN COMMANDS",
|
||||
Description: `
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ type BlockChain struct {
|
|||
// txLookupLimit is the maximum number of blocks from head whose tx indices
|
||||
// are reserved:
|
||||
// * 0: means no limit and regenerate any missing indexes
|
||||
// * N: means N block limit [HEAD-N, HEAD] and delete extra indexes
|
||||
// * N: means N block limit [HEAD-N+1, HEAD] and delete extra indexes
|
||||
// * nil: disable tx reindexer/deleter, but still index new blocks
|
||||
txLookupLimit uint64
|
||||
|
||||
|
|
@ -1112,8 +1112,16 @@ func (bc *BlockChain) InsertReceiptChain(blockChain types.Blocks, receiptChain [
|
|||
// * If all ancient tx indices are required to be reserved(txlookuplimit is even higher than ancientlimit)
|
||||
// * If block number is large enough to be regarded as a recent block
|
||||
// It means blocks below the ancientLimit-txlookupLimit won't be indexed.
|
||||
//
|
||||
// But if the `TxIndexTail` is not nil, e.g. Geth is initialized with
|
||||
// an external ancient database, during the setup, blockchain will start
|
||||
// a background routine to re-indexed all indices in [ancients - txlookupLimit, ancients)
|
||||
// range. In this case, all tx indices of newly imported blocks should be
|
||||
// generated.
|
||||
if bc.txLookupLimit == 0 || ancientLimit <= bc.txLookupLimit || block.NumberU64() >= ancientLimit-bc.txLookupLimit {
|
||||
rawdb.WriteTxLookupEntries(batch, block)
|
||||
} else if rawdb.ReadTxIndexTail(bc.db) != nil {
|
||||
rawdb.WriteTxLookupEntries(batch, block)
|
||||
}
|
||||
stats.processed++
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue