|
|
|
@ -33,9 +33,6 @@ type Config struct { |
|
|
|
|
Preimages bool // Flag whether the preimage of node key is recorded
|
|
|
|
|
HashDB *hashdb.Config // Configs for hash-based scheme
|
|
|
|
|
PathDB *pathdb.Config // Configs for experimental path-based scheme
|
|
|
|
|
|
|
|
|
|
// Testing hooks
|
|
|
|
|
OnCommit func(states *triestate.Set) // Hook invoked when commit is performed
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// HashDefaults represents a config for using hash-based scheme with
|
|
|
|
@ -88,20 +85,6 @@ type Database struct { |
|
|
|
|
backend backend // The backend for managing trie nodes
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// prepare initializes the database with provided configs, but the
|
|
|
|
|
// database backend is still left as nil.
|
|
|
|
|
func prepare(diskdb ethdb.Database, config *Config) *Database { |
|
|
|
|
var preimages *preimageStore |
|
|
|
|
if config != nil && config.Preimages { |
|
|
|
|
preimages = newPreimageStore(diskdb) |
|
|
|
|
} |
|
|
|
|
return &Database{ |
|
|
|
|
config: config, |
|
|
|
|
diskdb: diskdb, |
|
|
|
|
preimages: preimages, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NewDatabase initializes the trie database with default settings, note
|
|
|
|
|
// the legacy hash-based scheme is used by default.
|
|
|
|
|
func NewDatabase(diskdb ethdb.Database, config *Config) *Database { |
|
|
|
@ -149,9 +132,6 @@ func (db *Database) Reader(blockRoot common.Hash) (Reader, error) { |
|
|
|
|
// The passed in maps(nodes, states) will be retained to avoid copying everything.
|
|
|
|
|
// Therefore, these maps must not be changed afterwards.
|
|
|
|
|
func (db *Database) Update(root common.Hash, parent common.Hash, block uint64, nodes *trienode.MergedNodeSet, states *triestate.Set) error { |
|
|
|
|
if db.config != nil && db.config.OnCommit != nil { |
|
|
|
|
db.config.OnCommit(states) |
|
|
|
|
} |
|
|
|
|
if db.preimages != nil { |
|
|
|
|
db.preimages.commit(false) |
|
|
|
|
} |
|
|
|
|