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

Method ForEachStorage

core/state/statedb.go:433–452  ·  view source on GitHub ↗
(addr common.Address, cb func(key, value common.Hash) bool)

Source from the content-addressed store, hash-verified

431}
432
433func (db *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool) {
434 so := db.getStateObject(addr)
435 if so == nil {
436 return
437 }
438
439 // When iterating over the storage check the cache first
440 for h, value := range so.cachedStorage {
441 cb(h, value)
442 }
443
444 it := trie.NewIterator(so.getTrie(db.db).NodeIterator(nil))
445 for it.Next() {
446 // ignore cached values
447 key := common.BytesToHash(db.trie.GetKey(it.Key))
448 if _, ok := so.cachedStorage[key]; !ok {
449 cb(key, common.BytesToHash(it.Value))
450 }
451 }
452}
453
454// Copy creates a deep, independent copy of the state.
455// Snapshots of the copied state cannot be applied to the copy.

Callers

nothing calls this directly

Calls 6

getStateObjectMethod · 0.95
NewIteratorMethod · 0.80
NodeIteratorMethod · 0.80
getTrieMethod · 0.80
GetKeyMethod · 0.65
NextMethod · 0.45

Tested by

no test coverage detected