mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-17 04:11:37 +00:00
cmd/utils: add IsSet checks for config fields in MakeChain
Fields like `Preimages`, `NoPrefetch`, `StateHistory`, `TrienodeHistory`, `NodeFullValueCheckpoint`, and `StateSizeTracking` in `MakeChain` now use `ethconfig.Defaults` and only override when CLI flags are explicitly set. Matches the pattern in `SetEthConfig`.
This commit is contained in:
parent
fc43170cdd
commit
17bec615f8
1 changed files with 25 additions and 7 deletions
|
|
@ -2423,16 +2423,16 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
||||||
}
|
}
|
||||||
options := &core.BlockChainConfig{
|
options := &core.BlockChainConfig{
|
||||||
TrieCleanLimit: ethconfig.Defaults.TrieCleanCache,
|
TrieCleanLimit: ethconfig.Defaults.TrieCleanCache,
|
||||||
NoPrefetch: ctx.Bool(CacheNoPrefetchFlag.Name),
|
NoPrefetch: ethconfig.Defaults.NoPrefetch,
|
||||||
TrieDirtyLimit: ethconfig.Defaults.TrieDirtyCache,
|
TrieDirtyLimit: ethconfig.Defaults.TrieDirtyCache,
|
||||||
ArchiveMode: ctx.String(GCModeFlag.Name) == "archive",
|
ArchiveMode: ctx.String(GCModeFlag.Name) == "archive",
|
||||||
TrieTimeLimit: ethconfig.Defaults.TrieTimeout,
|
TrieTimeLimit: ethconfig.Defaults.TrieTimeout,
|
||||||
SnapshotLimit: ethconfig.Defaults.SnapshotCache,
|
SnapshotLimit: ethconfig.Defaults.SnapshotCache,
|
||||||
Preimages: ctx.Bool(CachePreimagesFlag.Name),
|
Preimages: ethconfig.Defaults.Preimages,
|
||||||
StateScheme: scheme,
|
StateScheme: scheme,
|
||||||
StateHistory: ctx.Uint64(StateHistoryFlag.Name),
|
StateHistory: ethconfig.Defaults.StateHistory,
|
||||||
TrienodeHistory: ctx.Int64(TrienodeHistoryFlag.Name),
|
TrienodeHistory: ethconfig.Defaults.TrienodeHistory,
|
||||||
NodeFullValueCheckpoint: uint32(ctx.Uint(TrienodeHistoryFullValueCheckpointFlag.Name)),
|
NodeFullValueCheckpoint: ethconfig.Defaults.NodeFullValueCheckpoint,
|
||||||
|
|
||||||
// Disable transaction indexing/unindexing.
|
// Disable transaction indexing/unindexing.
|
||||||
TxLookupLimit: -1,
|
TxLookupLimit: -1,
|
||||||
|
|
@ -2444,12 +2444,30 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
||||||
TrieJournalDirectory: stack.ResolvePath("triedb"),
|
TrieJournalDirectory: stack.ResolvePath("triedb"),
|
||||||
|
|
||||||
// Enable state size tracking if enabled
|
// Enable state size tracking if enabled
|
||||||
StateSizeTracking: ctx.Bool(StateSizeTrackingFlag.Name),
|
StateSizeTracking: ethconfig.Defaults.EnableStateSizeTracking,
|
||||||
|
|
||||||
// Configure the slow block statistic logger (disabled by default)
|
// Configure the slow block statistic logger (disabled by default)
|
||||||
SlowBlockThreshold: ethconfig.Defaults.SlowBlockThreshold,
|
SlowBlockThreshold: ethconfig.Defaults.SlowBlockThreshold,
|
||||||
}
|
}
|
||||||
// Only enable slow block logging if the flag was explicitly set
|
// Only override with CLI flags if explicitly set
|
||||||
|
if ctx.IsSet(CacheNoPrefetchFlag.Name) {
|
||||||
|
options.NoPrefetch = ctx.Bool(CacheNoPrefetchFlag.Name)
|
||||||
|
}
|
||||||
|
if ctx.IsSet(CachePreimagesFlag.Name) {
|
||||||
|
options.Preimages = ctx.Bool(CachePreimagesFlag.Name)
|
||||||
|
}
|
||||||
|
if ctx.IsSet(StateHistoryFlag.Name) {
|
||||||
|
options.StateHistory = ctx.Uint64(StateHistoryFlag.Name)
|
||||||
|
}
|
||||||
|
if ctx.IsSet(TrienodeHistoryFlag.Name) {
|
||||||
|
options.TrienodeHistory = ctx.Int64(TrienodeHistoryFlag.Name)
|
||||||
|
}
|
||||||
|
if ctx.IsSet(TrienodeHistoryFullValueCheckpointFlag.Name) {
|
||||||
|
options.NodeFullValueCheckpoint = uint32(ctx.Uint(TrienodeHistoryFullValueCheckpointFlag.Name))
|
||||||
|
}
|
||||||
|
if ctx.IsSet(StateSizeTrackingFlag.Name) {
|
||||||
|
options.StateSizeTracking = ctx.Bool(StateSizeTrackingFlag.Name)
|
||||||
|
}
|
||||||
if ctx.IsSet(LogSlowBlockFlag.Name) {
|
if ctx.IsSet(LogSlowBlockFlag.Name) {
|
||||||
options.SlowBlockThreshold = ctx.Duration(LogSlowBlockFlag.Name)
|
options.SlowBlockThreshold = ctx.Duration(LogSlowBlockFlag.Name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue