mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 06:06:44 +00:00
triedb/pathdb: only enable history indexing in archive mode
This commit is contained in:
parent
ca0a0feaf7
commit
d326be0eba
1 changed files with 14 additions and 7 deletions
|
|
@ -114,11 +114,12 @@ type layer interface {
|
||||||
|
|
||||||
// Config contains the settings for database.
|
// Config contains the settings for database.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
StateHistory uint64 // Number of recent blocks to maintain state history for
|
StateHistory uint64 // Number of recent blocks to maintain state history for
|
||||||
TrieCleanSize int // Maximum memory allowance (in bytes) for caching clean trie nodes
|
EnableStateIndexing bool // Whether to enable state history indexing for external state access
|
||||||
StateCleanSize int // Maximum memory allowance (in bytes) for caching clean state data
|
TrieCleanSize int // Maximum memory allowance (in bytes) for caching clean trie nodes
|
||||||
WriteBufferSize int // Maximum memory allowance (in bytes) for write buffer
|
StateCleanSize int // Maximum memory allowance (in bytes) for caching clean state data
|
||||||
ReadOnly bool // Flag whether the database is opened in read only mode
|
WriteBufferSize int // Maximum memory allowance (in bytes) for write buffer
|
||||||
|
ReadOnly bool // Flag whether the database is opened in read only mode
|
||||||
|
|
||||||
// Testing configurations
|
// Testing configurations
|
||||||
SnapshotNoBuild bool // Flag Whether the state generation is allowed
|
SnapshotNoBuild bool // Flag Whether the state generation is allowed
|
||||||
|
|
@ -149,7 +150,12 @@ func (c *Config) fields() []interface{} {
|
||||||
list = append(list, "triecache", common.StorageSize(c.TrieCleanSize))
|
list = append(list, "triecache", common.StorageSize(c.TrieCleanSize))
|
||||||
list = append(list, "statecache", common.StorageSize(c.StateCleanSize))
|
list = append(list, "statecache", common.StorageSize(c.StateCleanSize))
|
||||||
list = append(list, "buffer", common.StorageSize(c.WriteBufferSize))
|
list = append(list, "buffer", common.StorageSize(c.WriteBufferSize))
|
||||||
list = append(list, "history", c.StateHistory)
|
|
||||||
|
if c.StateHistory == 0 {
|
||||||
|
list = append(list, "history", "entire chain")
|
||||||
|
} else {
|
||||||
|
list = append(list, "history", fmt.Sprintf("last %d blocks", c.StateHistory))
|
||||||
|
}
|
||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -264,8 +270,9 @@ func New(diskdb ethdb.Database, config *Config, isVerkle bool) *Database {
|
||||||
log.Crit("Failed to setup the generator", "err", err)
|
log.Crit("Failed to setup the generator", "err", err)
|
||||||
}
|
}
|
||||||
// TODO (rjl493456442) disable the background indexing in read-only mode
|
// TODO (rjl493456442) disable the background indexing in read-only mode
|
||||||
if db.freezer != nil {
|
if db.freezer != nil && db.config.EnableStateIndexing {
|
||||||
db.indexer = newHistoryIndexer(db.diskdb, db.freezer, db.tree.bottom().stateID())
|
db.indexer = newHistoryIndexer(db.diskdb, db.freezer, db.tree.bottom().stateID())
|
||||||
|
log.Info("Enabled state history indexing")
|
||||||
}
|
}
|
||||||
fields := config.fields()
|
fields := config.fields()
|
||||||
if db.isVerkle {
|
if db.isVerkle {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue