diff --git a/eth/backend.go b/eth/backend.go index 2da780feab..39a4e9838e 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -344,7 +344,12 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { shouldPreserve := func(header *types.Header) bool { return false } - eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, shouldPreserve, &config.TransactionHistory, bcOps...) + txLookupLimit := &config.TransactionHistory + if config.DisableTxIndexer { + log.Warn("The TxIndexer is disabled. Please note that the next time you re-enable it, it may affect the node performance because of rebuilding the tx index.") + txLookupLimit = nil + } + eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, shouldPreserve, txLookupLimit, bcOps...) if err != nil { return nil, err } diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 1ec64a122d..90b798f771 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -124,6 +124,8 @@ type Config struct { PathSyncFlush bool `toml:",omitempty"` // State scheme used to store ethereum state and merkle trie nodes on top JournalFileEnabled bool // Whether the TrieJournal is stored using journal file + DisableTxIndexer bool `toml:",omitempty"` // Whether to enable the transaction indexer + // RequiredBlocks is a set of block number -> hash mappings which must be in the // canonical chain of all remote peers. Setting the option makes geth verify the // presence of these blocks for every new peer connection. diff --git a/eth/ethconfig/gen_config.go b/eth/ethconfig/gen_config.go index 8089b03538..d8b87e2bd6 100644 --- a/eth/ethconfig/gen_config.go +++ b/eth/ethconfig/gen_config.go @@ -39,6 +39,7 @@ func (c Config) MarshalTOML() (interface{}, error) { StateScheme string `toml:",omitempty"` PathSyncFlush bool `toml:",omitempty"` JournalFileEnabled bool + DisableTxIndexer bool `toml:",omitempty"` RequiredBlocks map[uint64]common.Hash `toml:"-"` SkipBcVersionCheck bool `toml:"-"` DatabaseHandles int `toml:"-"` @@ -95,6 +96,7 @@ func (c Config) MarshalTOML() (interface{}, error) { enc.StateScheme = c.StateScheme enc.PathSyncFlush = c.PathSyncFlush enc.JournalFileEnabled = c.JournalFileEnabled + enc.DisableTxIndexer = c.DisableTxIndexer enc.RequiredBlocks = c.RequiredBlocks enc.SkipBcVersionCheck = c.SkipBcVersionCheck enc.DatabaseHandles = c.DatabaseHandles @@ -155,6 +157,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { StateScheme *string `toml:",omitempty"` PathSyncFlush *bool `toml:",omitempty"` JournalFileEnabled *bool + DisableTxIndexer *bool `toml:",omitempty"` RequiredBlocks map[uint64]common.Hash `toml:"-"` SkipBcVersionCheck *bool `toml:"-"` DatabaseHandles *int `toml:"-"` @@ -258,6 +261,9 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error { if dec.JournalFileEnabled != nil { c.JournalFileEnabled = *dec.JournalFileEnabled } + if dec.DisableTxIndexer != nil { + c.DisableTxIndexer = *dec.DisableTxIndexer + } if dec.RequiredBlocks != nil { c.RequiredBlocks = dec.RequiredBlocks }