Skip to content

Commit

Permalink
trie: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
rjl493456442 committed Sep 20, 2022
1 parent cdd1f3d commit 42e954e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions trie/trie.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,19 @@ func (t *Trie) Copy() *Trie {
}
}

// New creates a trie with an existing root node from db and an assigned
// owner for storage proximity.
// New creates the trie instance with provided information and read-only database.
//
// If root is the zero hash or the sha3 hash of an empty string, the
// trie is initially empty and does not require a database. Otherwise,
// New will panic if db is nil and returns a MissingNodeError if root does
// not exist in the database. Accessing the trie loads nodes from db on demand.
// - stateRoot: the identifier for selecting state to access trie nodes.
// If the corresponding state is not available, an error will be returned.
//
// - owner: the identifier of second-layer trie(namely the storage trie in
// ethereum). It's the hash of the corresponding contract address
// used for uniquely identifying trie nodes. It's empty for account trie.
//
// - root: the root hash of the trie. If root is the zero hash or the sha3
// hash of an empty string, then trie is initially empty. Otherwise,
// the root node must be present in database or returns a MissingNodeError
// if not.
func New(stateRoot common.Hash, owner common.Hash, root common.Hash, db NodeReader) (*Trie, error) {
reader, err := newTrieReader(owner, stateRoot, db)
if err != nil {
Expand Down

0 comments on commit 42e954e

Please sign in to comment.