cmd, core, eth: background transaction indexing (#20302)
* cmd, core, eth: init tx lookup in background * core/rawdb: tiny log fixes to make it clearer what's happening * core, eth: fix rebase errors * core/rawdb: make reindexing less generic, but more optimal * rlp: implement rlp list iterator * core/rawdb: new implementation of tx indexing/unindex using generic tx iterator and hashing rlp-data * core/rawdb, cmd/utils: fix review concerns * cmd/utils: fix merge issue * core/rawdb: add some log formatting polishes Co-authored-by: rjl493456442 <garyrong0905@gmail.com> Co-authored-by: Péter Szilágyi <peterke@gmail.com>
This commit is contained in:
committed by
GitHub
parent
6f54ae24cd
commit
4535230059
19
eth/sync.go
19
eth/sync.go
@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
@ -285,6 +286,24 @@ func (cs *chainSyncer) startSync(op *chainSyncOp) {
|
||||
|
||||
// doSync synchronizes the local blockchain with a remote peer.
|
||||
func (pm *ProtocolManager) doSync(op *chainSyncOp) error {
|
||||
if op.mode == downloader.FastSync {
|
||||
// Before launch the fast sync, we have to ensure user uses the same
|
||||
// txlookup limit.
|
||||
// The main concern here is: during the fast sync Geth won't index the
|
||||
// block(generate tx indices) before the HEAD-limit. But if user changes
|
||||
// the limit in the next fast sync(e.g. user kill Geth manually and
|
||||
// restart) then it will be hard for Geth to figure out the oldest block
|
||||
// has been indexed. So here for the user-experience wise, it's non-optimal
|
||||
// that user can't change limit during the fast sync. If changed, Geth
|
||||
// will just blindly use the original one.
|
||||
limit := pm.blockchain.TxLookupLimit()
|
||||
if stored := rawdb.ReadFastTxLookupLimit(pm.chaindb); stored == nil {
|
||||
rawdb.WriteFastTxLookupLimit(pm.chaindb, limit)
|
||||
} else if *stored != limit {
|
||||
pm.blockchain.SetTxLookupLimit(*stored)
|
||||
log.Warn("Update txLookup limit", "provided", limit, "updated", *stored)
|
||||
}
|
||||
}
|
||||
// Run the sync cycle, and disable fast sync if we're past the pivot block
|
||||
err := pm.downloader.Synchronise(op.peer.id, op.head, op.td, op.mode)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user