mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
eth: fix storageRangeAt return value
StorageRangeAt use the Split function to decode the values.
This commit is contained in:
parent
b81a9cd829
commit
667fb455a9
1 changed files with 8 additions and 4 deletions
12
eth/api.go
12
eth/api.go
|
|
@ -615,14 +615,18 @@ func (api *PrivateDebugAPI) StorageRangeAt(ctx context.Context, blockHash common
|
|||
if st == nil {
|
||||
return StorageRangeResult{}, fmt.Errorf("account %x doesn't exist", contractAddress)
|
||||
}
|
||||
return storageRangeAt(st, keyStart, maxResult), nil
|
||||
return storageRangeAt(st, keyStart, maxResult)
|
||||
}
|
||||
|
||||
func storageRangeAt(st state.Trie, start []byte, maxResult int) StorageRangeResult {
|
||||
func storageRangeAt(st state.Trie, start []byte, maxResult int) (StorageRangeResult, error) {
|
||||
it := trie.NewIterator(st.NodeIterator(start))
|
||||
result := StorageRangeResult{Storage: storageMap{}}
|
||||
for i := 0; i < maxResult && it.Next(); i++ {
|
||||
e := storageEntry{Value: common.BytesToHash(it.Value)}
|
||||
_, content, _, err := rlp.Split(it.Value)
|
||||
if err != nil {
|
||||
return StorageRangeResult{}, err
|
||||
}
|
||||
e := storageEntry{Value: common.BytesToHash(content)}
|
||||
if preimage := st.GetKey(it.Key); preimage != nil {
|
||||
preimage := common.BytesToHash(preimage)
|
||||
e.Key = &preimage
|
||||
|
|
@ -634,5 +638,5 @@ func storageRangeAt(st state.Trie, start []byte, maxResult int) StorageRangeResu
|
|||
next := common.BytesToHash(it.Key)
|
||||
result.NextKey = &next
|
||||
}
|
||||
return result
|
||||
return result, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue