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

Method updateTrie

core/state/state_object.go:201–214  ·  view source on GitHub ↗

updateTrie writes cached storage modifications into the object's storage trie.

(db Database)

Source from the content-addressed store, hash-verified

199
200// updateTrie writes cached storage modifications into the object's storage trie.
201func (self *stateObject) updateTrie(db Database) Trie {
202 tr := self.getTrie(db)
203 for key, value := range self.dirtyStorage {
204 delete(self.dirtyStorage, key)
205 if (value == common.Hash{}) {
206 self.setError(tr.TryDelete(key[:]))
207 continue
208 }
209 // Encoding []byte cannot fail, ok to ignore the error.
210 v, _ := rlp.EncodeToBytes(bytes.TrimLeft(value[:], "\x00"))
211 self.setError(tr.TryUpdate(key[:], v))
212 }
213 return tr
214}
215
216// UpdateRoot sets the trie root to the current root hash of
217func (self *stateObject) updateRoot(db Database) {

Callers 3

updateRootMethod · 0.95
CommitTrieMethod · 0.95
StorageTrieMethod · 0.80

Calls 4

getTrieMethod · 0.95
setErrorMethod · 0.95
TryDeleteMethod · 0.80
TryUpdateMethod · 0.80

Tested by

no test coverage detected