(addr common.Address, cb func(key, value common.Hash) bool)
| 431 | } |
| 432 | |
| 433 | func (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. |
nothing calls this directly
no test coverage detected