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

Function storageRangeAt

protocols/cpc/api.go:394–415  ·  view source on GitHub ↗
(st state.Trie, start []byte, maxResult int)

Source from the content-addressed store, hash-verified

392}
393
394func storageRangeAt(st state.Trie, start []byte, maxResult int) (StorageRangeResult, error) {
395 it := trie.NewIterator(st.NodeIterator(start))
396 result := StorageRangeResult{Storage: storageMap{}}
397 for i := 0; i < maxResult && it.Next(); i++ {
398 _, content, _, err := rlp.Split(it.Value)
399 if err != nil {
400 return StorageRangeResult{}, err
401 }
402 e := storageEntry{Value: common.BytesToHash(content)}
403 if preimage := st.GetKey(it.Key); preimage != nil {
404 preimage := common.BytesToHash(preimage)
405 e.Key = &preimage
406 }
407 result.Storage[common.BytesToHash(it.Key)] = e
408 }
409 // Add the 'next key' so clients can continue downloading.
410 if it.Next() {
411 next := common.BytesToHash(it.Key)
412 result.NextKey = &next
413 }
414 return result, nil
415}
416
417// GetModifiedAccountsByNumber returns all accounts that have changed between the
418// two blocks specified. A change is defined as a difference in nonce, balance,

Callers 2

StorageRangeAtMethod · 0.85
TestStorageRangeAtFunction · 0.85

Calls 4

NewIteratorMethod · 0.80
NodeIteratorMethod · 0.80
GetKeyMethod · 0.65
NextMethod · 0.45

Tested by 1

TestStorageRangeAtFunction · 0.68