Skip to content

Commit

Permalink
log marker
Browse files Browse the repository at this point in the history
  • Loading branch information
bendanzhentan committed Jan 15, 2024
1 parent 277050f commit 0e5631b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions trie/proof.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"github.com/status-im/keycard-go/hexutils"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
Expand All @@ -42,30 +43,31 @@ func (t *Trie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) e
tn = t.root
)
key = keybytesToHex(key)
log.Info("bilibili Trie.Prove", "key1", hexutils.BytesToHex(keybytesToHex(key)), "key2", hexutils.BytesToHex(key), "fromLevel", fromLevel)
marker := key[:len(key)-1]
log.Info("bilibili Trie.Prove", "marker", hexutils.BytesToHex(marker), "key1", hexutils.BytesToHex(keybytesToHex(key)), "key2", hexutils.BytesToHex(key), "fromLevel", fromLevel)
i := 0
for len(key) > 0 && tn != nil {
switch n := tn.(type) {
case *shortNode:
if len(key) < len(n.Key) || !bytes.Equal(n.Key, key[:len(n.Key)]) {
// The trie doesn't contain the key.
tn = nil
log.Info("bilibili loop", "index", i, "type", "SHORT NODE", "note", "key not found")
log.Info("bilibili loop", "marker", hexutils.BytesToHex(marker), "index", i, "type", "SHORT NODE", "note", "key not found")
} else {
tn = n.Val
prefix = append(prefix, n.Key...)
key = key[len(n.Key):]
log.Info("bilibili loop", "index", i, "type", "SHORT NODE", "note", "key found")
log.Info("bilibili loop", "marker", hexutils.BytesToHex(marker), "index", i, "type", "SHORT NODE", "note", "key found")
}
nodes = append(nodes, n)
case *fullNode:
tn = n.Children[key[0]]
prefix = append(prefix, key[0])
key = key[1:]
nodes = append(nodes, n)
log.Info("bilibili loop", "index", i, "type", "FULL NODE")
log.Info("bilibili loop", "marker", hexutils.BytesToHex(marker), "index", i, "type", "FULL NODE")
case hashNode:
log.Info("bilibili loop", "index", i, "type", "HASH NODE")
log.Info("bilibili loop", "marker", hexutils.BytesToHex(marker), "index", i, "type", "HASH NODE")
// Retrieve the specified node from the underlying node reader.
// trie.resolveAndTrack is not used since in that function the
// loaded blob will be tracked, while it's not required here since
Expand Down Expand Up @@ -104,6 +106,7 @@ func (t *Trie) Prove(key []byte, fromLevel uint, proofDb ethdb.KeyValueWriter) e
}
}
}
time.Sleep(time.Second)
return nil
}

Expand Down

0 comments on commit 0e5631b

Please sign in to comment.