mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +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(preimages map[common.Hash][]byte)
|
||||
|
||||
// PreimageEnabled returns true if the preimage store is enabled.
|
||||
PreimageEnabled() bool
|
||||
}
|
||||
|
||||
// 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}
|
||||
|
||||
// link the preimage store if it's supported
|
||||
preimages, ok := db.(preimageStore)
|
||||
if ok {
|
||||
if preimages, ok := db.(preimageStore); ok && preimages.PreimageEnabled() {
|
||||
tr.preimages = preimages
|
||||
}
|
||||
return tr, nil
|
||||
|
|
|
|||
|
|
@ -213,6 +213,11 @@ func (db *Database) InsertPreimage(preimages map[common.Hash][]byte) {
|
|||
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
|
||||
// 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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue