mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
add PreimageEnabled indicator
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
959f00d922
commit
1ebe82d779
2 changed files with 9 additions and 2 deletions
|
|
@ -33,6 +33,9 @@ type preimageStore interface {
|
||||||
|
|
||||||
// InsertPreimage commits a set of preimages along with their hashes.
|
// InsertPreimage commits a set of preimages along with their hashes.
|
||||||
InsertPreimage(preimages map[common.Hash][]byte)
|
InsertPreimage(preimages map[common.Hash][]byte)
|
||||||
|
|
||||||
|
// PreimageEnabled returns true if the preimage store is enabled.
|
||||||
|
PreimageEnabled() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// SecureTrie is the old name of StateTrie.
|
// SecureTrie is the old name of StateTrie.
|
||||||
|
|
@ -84,8 +87,7 @@ func NewStateTrie(id *ID, db database.NodeDatabase) (*StateTrie, error) {
|
||||||
tr := &StateTrie{trie: *trie, db: db}
|
tr := &StateTrie{trie: *trie, db: db}
|
||||||
|
|
||||||
// link the preimage store if it's supported
|
// link the preimage store if it's supported
|
||||||
preimages, ok := db.(preimageStore)
|
if preimages, ok := db.(preimageStore); ok && preimages.PreimageEnabled() {
|
||||||
if ok {
|
|
||||||
tr.preimages = preimages
|
tr.preimages = preimages
|
||||||
}
|
}
|
||||||
return tr, nil
|
return tr, nil
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,11 @@ func (db *Database) InsertPreimage(preimages map[common.Hash][]byte) {
|
||||||
db.preimages.insertPreimage(preimages)
|
db.preimages.insertPreimage(preimages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PreimageEnabled returns the indicator if the pre-image store is enabled.
|
||||||
|
func (db *Database) PreimageEnabled() bool {
|
||||||
|
return db.preimages != nil
|
||||||
|
}
|
||||||
|
|
||||||
// Cap iteratively flushes old but still referenced trie nodes until the total
|
// Cap iteratively flushes old but still referenced trie nodes until the total
|
||||||
// memory usage goes below the given threshold. The held pre-images accumulated
|
// memory usage goes below the given threshold. The held pre-images accumulated
|
||||||
// up to this point will be flushed in case the size exceeds the threshold.
|
// up to this point will be flushed in case the size exceeds the threshold.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue