MCPcopy Create free account
hub / github.com/CPChain/chain / OpenTrie

Method OpenTrie

core/state/database.go:94–108  ·  view source on GitHub ↗

OpenTrie opens the main account trie.

(root common.Hash)

Source from the content-addressed store, hash-verified

92
93// OpenTrie opens the main account trie.
94func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) {
95 db.mu.Lock()
96 defer db.mu.Unlock()
97
98 for i := len(db.pastTries) - 1; i >= 0; i-- {
99 if db.pastTries[i].Hash() == root {
100 return cachedTrie{db.pastTries[i].Copy(), db}, nil
101 }
102 }
103 tr, err := trie.NewSecure(root, db.db, MaxTrieCacheGen)
104 if err != nil {
105 return nil, err
106 }
107 return cachedTrie{tr, db}, nil
108}
109
110func (db *cachingDB) pushTrie(t *trie.SecureTrie) {
111 db.mu.Lock()

Callers

nothing calls this directly

Calls 4

LockMethod · 0.80
UnlockMethod · 0.80
HashMethod · 0.65
CopyMethod · 0.45

Tested by

no test coverage detected