diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index fd8c2cbb30..8739d49899 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1727,7 +1727,11 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai cache.TrieDirtyLimit = ctx.GlobalInt(CacheFlag.Name) * ctx.GlobalInt(CacheGCFlag.Name) / 100 } vmcfg := vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)} - chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg, nil, 0) + txLookupLimit := uint64(0) + if ctx.GlobalIsSet(TxLookupLimitFlag.Name) { + txLookupLimit = ctx.GlobalUint64(TxLookupLimitFlag.Name) + } + chain, err = core.NewBlockChain(chainDb, cache, config, engine, vmcfg, nil, txLookupLimit) if err != nil { Fatalf("Can't create BlockChain: %v", err) } diff --git a/core/blockchain.go b/core/blockchain.go index e86f1242de..9f9fec0936 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2074,10 +2074,15 @@ func (bc *BlockChain) update() { func (bc *BlockChain) maintainTxIndex() { // initialiseIndices inits tx indices into the database if `TxIndexTail` // is missing in database. - // Note for archive sync or fast sync, this code path will only be triggered + // + // Note for archive sync or full sync, this code path will only be triggered // after importing the first batch of blocks(e.g. 1024). But these block // actually are already indexed. So a binary search will be performed to // skip reindexing. + // + // Besides for old node database which actually contains all indices but + // without `TxIndexTail` in database, binary search can also help to skip + // reindexing. initialiseIndices := func(head uint64, done chan struct{}) { defer func() { done <- struct{}{} }() diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 255f553db4..fa0d3f2340 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -1721,7 +1721,7 @@ func (d *Downloader) commitPivotBlock(result *fetchResult) error { if _, err := d.blockchain.InsertReceiptChain([]*types.Block{block}, []types.Receipts{result.Receipts}, d.ancientLimit); err != nil { return err } - // Use origin block number + 1 as the number of the first inserted block. + // Use origin block number + 1 as the first inserted block number d.syncStatsLock.RLock() from := d.syncStatsChainOrigin + 1 d.syncStatsLock.RUnlock()