@@ -68,6 +68,24 @@ type layer interface {
6868 // - no error will be returned if the requested node is not found in database.
6969 node (owner common.Hash , path []byte , depth int ) ([]byte , common.Hash , * nodeLoc , error )
7070
71+ // account directly retrieves the account RLP associated with a particular
72+ // hash in the slim data format. An error will be returned if the read
73+ // operation exits abnormally. Specifically, if the layer is already stale.
74+ //
75+ // Note:
76+ // - the returned account is not a copy, please don't modify it.
77+ // - no error will be returned if the requested account is not found in database.
78+ account (hash common.Hash , depth int ) ([]byte , error )
79+
80+ // storage directly retrieves the storage data associated with a particular hash,
81+ // within a particular account. An error will be returned if the read operation
82+ // exits abnormally. Specifically, if the layer is already stale.
83+ //
84+ // Note:
85+ // - the returned storage data is not a copy, please don't modify it.
86+ // - no error will be returned if the requested slot is not found in database.
87+ storage (accountHash , storageHash common.Hash , depth int ) ([]byte , error )
88+
7189 // rootHash returns the root hash for which this layer was made.
7290 rootHash () common.Hash
7391
@@ -130,17 +148,18 @@ var Defaults = &Config{
130148// ReadOnly is the config in order to open database in read only mode.
131149var ReadOnly = & Config {ReadOnly : true }
132150
133- // Database is a multiple-layered structure for maintaining in-memory trie nodes.
134- // It consists of one persistent base layer backed by a key-value store, on top
135- // of which arbitrarily many in-memory diff layers are stacked. The memory diffs
136- // can form a tree with branching, but the disk layer is singleton and common to
137- // all. If a reorg goes deeper than the disk layer, a batch of reverse diffs can
138- // be applied to rollback. The deepest reorg that can be handled depends on the
139- // amount of state histories tracked in the disk.
151+ // Database is a multiple-layered structure for maintaining in-memory states
152+ // along with its dirty trie nodes. It consists of one persistent base layer
153+ // backed by a key-value store, on top of which arbitrarily many in-memory diff
154+ // layers are stacked. The memory diffs can form a tree with branching, but the
155+ // disk layer is singleton and common to all. If a reorg goes deeper than the
156+ // disk layer, a batch of reverse diffs can be applied to rollback. The deepest
157+ // reorg that can be handled depends on the amount of state histories tracked
158+ // in the disk.
140159//
141160// At most one readable and writable database can be opened at the same time in
142- // the whole system which ensures that only one database writer can operate disk
143- // state. Unexpected open operations can cause the system to panic.
161+ // the whole system which ensures that only one database writer can operate the
162+ // persistent state. Unexpected open operations can cause the system to panic.
144163type Database struct {
145164 // readOnly is the flag whether the mutation is allowed to be applied.
146165 // It will be set automatically when the database is journaled during
@@ -358,7 +377,7 @@ func (db *Database) Enable(root common.Hash) error {
358377 }
359378 // Re-construct a new disk layer backed by persistent state
360379 // with **empty clean cache and node buffer**.
361- db .tree .reset (newDiskLayer (root , 0 , db , nil , newBuffer (db .config .WriteBufferSize , nil , 0 )))
380+ db .tree .reset (newDiskLayer (root , 0 , db , nil , newBuffer (db .config .WriteBufferSize , nil , nil , 0 )))
362381
363382 // Re-enable the database as the final step.
364383 db .waitSync = false
0 commit comments