mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
core: remove *uint64 for TxLookupLimit
This commit is contained in:
parent
43cb1eed45
commit
6fa66e40a3
4 changed files with 19 additions and 26 deletions
|
|
@ -175,15 +175,12 @@ type BlockChainConfig struct {
|
|||
Overrides *ChainOverrides // Optional chain config overrides
|
||||
VmConfig vm.Config // Config options for the EVM Interpreter
|
||||
|
||||
// TxLookupLimit specifies the maximum number of blocks from head whose tx
|
||||
// indices are reserved.
|
||||
// TxLookupLimit specifies the maximum number of blocks from head for which
|
||||
// transaction hashes will be indexed.
|
||||
//
|
||||
// If the value is zero, then the transaction indexes of the entire chain
|
||||
// should be reserved.
|
||||
//
|
||||
// If the value is nil, it means the transaction indexing is disabled.
|
||||
// For instance, the chain is opened in read-only mode.
|
||||
TxLookupLimit *uint64
|
||||
// If the value is zero, all transactions of the entire chain will be indexed.
|
||||
// If the value is -1, indexing is disabled. This is the default setting.
|
||||
TxLookupLimit int64
|
||||
}
|
||||
|
||||
// DefaultConfig returns the default config.
|
||||
|
|
@ -197,6 +194,9 @@ func DefaultConfig() *BlockChainConfig {
|
|||
SnapshotLimit: 256,
|
||||
SnapshotWait: true,
|
||||
ChainHistoryMode: history.KeepAll,
|
||||
// Transaction indexing is disabled by default.
|
||||
// This is appropriate for most unit tests.
|
||||
TxLookupLimit: -1,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -501,8 +501,8 @@ func NewBlockChain(db ethdb.Database, genesis *Genesis, engine consensus.Engine,
|
|||
}
|
||||
|
||||
// Start tx indexer if it's enabled.
|
||||
if bc.cfg.TxLookupLimit != nil {
|
||||
bc.txIndexer = newTxIndexer(*bc.cfg.TxLookupLimit, bc)
|
||||
if bc.cfg.TxLookupLimit >= 0 {
|
||||
bc.txIndexer = newTxIndexer(uint64(bc.cfg.TxLookupLimit), bc)
|
||||
}
|
||||
return bc, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package eth
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
|
@ -205,10 +206,11 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
|
|||
StateHistory: config.StateHistory,
|
||||
StateScheme: scheme,
|
||||
ChainHistoryMode: config.HistoryMode,
|
||||
TxLookupLimit: int64(min(config.TransactionHistory, math.MaxInt64)),
|
||||
VmConfig: vmConfig,
|
||||
TxLookupLimit: &config.TransactionHistory,
|
||||
}
|
||||
)
|
||||
|
||||
if config.VMTrace != "" {
|
||||
traceConfig := json.RawMessage("{}")
|
||||
if config.VMTraceJsonConfig != "" {
|
||||
|
|
|
|||
|
|
@ -276,9 +276,8 @@ func testFilters(t *testing.T, history uint64, noHistory bool) {
|
|||
gen.AddTx(tx)
|
||||
}
|
||||
})
|
||||
var l uint64
|
||||
options := core.DefaultConfig().WithStateScheme(rawdb.HashScheme)
|
||||
options.TxLookupLimit = &l
|
||||
options.TxLookupLimit = 0 // index all txs
|
||||
bc, err := core.NewBlockChain(db, gspec, ethash.NewFaker(), options)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
@ -436,9 +435,8 @@ func TestRangeLogs(t *testing.T) {
|
|||
}
|
||||
chain, _ := core.GenerateChain(gspec.Config, gspec.ToBlock(), ethash.NewFaker(), db, 1000, func(i int, gen *core.BlockGen) {})
|
||||
|
||||
var l uint64
|
||||
options := core.DefaultConfig().WithStateScheme(rawdb.HashScheme)
|
||||
options.TxLookupLimit = &l
|
||||
options.TxLookupLimit = 0 // index all txs
|
||||
bc, err := core.NewBlockChain(db, gspec, ethash.NewFaker(), options)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
|
|
|||
|
|
@ -442,19 +442,12 @@ type testBackend struct {
|
|||
}
|
||||
|
||||
func newTestBackend(t *testing.T, n int, gspec *core.Genesis, engine consensus.Engine, generator func(i int, b *core.BlockGen)) *testBackend {
|
||||
var (
|
||||
txLookupLimit = uint64(0)
|
||||
options = &core.BlockChainConfig{
|
||||
TrieCleanLimit: 256,
|
||||
TrieDirtyLimit: 256,
|
||||
TrieTimeLimit: 5 * time.Minute,
|
||||
SnapshotLimit: 0,
|
||||
ArchiveMode: true, // Archive mode
|
||||
TxLookupLimit: &txLookupLimit,
|
||||
}
|
||||
)
|
||||
options := core.DefaultConfig().WithArchive(true)
|
||||
options.TxLookupLimit = 0 // index all txs
|
||||
|
||||
accman, acc := newTestAccountManager(t)
|
||||
gspec.Alloc[acc.Address] = types.Account{Balance: big.NewInt(params.Ether)}
|
||||
|
||||
// Generate blocks for testing
|
||||
db, blocks, _ := core.GenerateChainWithGenesis(gspec, engine, n, generator)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue