aboutsummaryrefslogtreecommitdiffstats
path: root/light
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-04-25 16:10:21 +0800
committerGitHub <noreply@github.com>2017-04-25 16:10:20 +0800
commitba3bcd16a6d99bc0e58516556df8e96b730c2d60 (patch)
treee6622b6dd3ca30a28ea68ad69d0d1b2d675b7bb3 /light
parent7cc6abeef6ec0b6c5fd5a94920fa79157cdfcd37 (diff)
parent207bd7d2cddbf16ac2cb870fd6a1c558f02fd8ac (diff)
downloadgo-tangerine-ba3bcd16a6d99bc0e58516556df8e96b730c2d60.tar
go-tangerine-ba3bcd16a6d99bc0e58516556df8e96b730c2d60.tar.gz
go-tangerine-ba3bcd16a6d99bc0e58516556df8e96b730c2d60.tar.bz2
go-tangerine-ba3bcd16a6d99bc0e58516556df8e96b730c2d60.tar.lz
go-tangerine-ba3bcd16a6d99bc0e58516556df8e96b730c2d60.tar.xz
go-tangerine-ba3bcd16a6d99bc0e58516556df8e96b730c2d60.tar.zst
go-tangerine-ba3bcd16a6d99bc0e58516556df8e96b730c2d60.zip
Merge pull request #14350 from fjl/trie-iterator-skip-2
eth: add debug_storageRangeAt
Diffstat (limited to 'light')
-rw-r--r--light/trie.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/light/trie.go b/light/trie.go
index 1440f2fbf..2988a16cf 100644
--- a/light/trie.go
+++ b/light/trie.go
@@ -19,6 +19,7 @@ package light
import (
"context"
+ "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/trie"
)
@@ -46,26 +47,18 @@ func NewLightTrie(id *TrieID, odr OdrBackend, useFakeMap bool) *LightTrie {
// retrieveKey retrieves a single key, returns true and stores nodes in local
// database if successful
func (t *LightTrie) retrieveKey(ctx context.Context, key []byte) bool {
- r := &TrieRequest{Id: t.id, Key: key}
+ r := &TrieRequest{Id: t.id, Key: crypto.Keccak256(key)}
return t.odr.Retrieve(ctx, r) == nil
}
// do tries and retries to execute a function until it returns with no error or
// an error type other than MissingNodeError
-func (t *LightTrie) do(ctx context.Context, fallbackKey []byte, fn func() error) error {
+func (t *LightTrie) do(ctx context.Context, key []byte, fn func() error) error {
err := fn()
for err != nil {
- mn, ok := err.(*trie.MissingNodeError)
- if !ok {
+ if _, ok := err.(*trie.MissingNodeError); !ok {
return err
}
-
- var key []byte
- if mn.PrefixLen+mn.SuffixLen > 0 {
- key = mn.Key
- } else {
- key = fallbackKey
- }
if !t.retrieveKey(ctx, key) {
break
}