comments
This commit is contained in:
parent
87c5033edf
commit
f6d9fa992d
@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// PrefixBoundIterator is a NodeIterator constrained by a lower & upper bound (as hex path prefixes)
|
||||||
type PrefixBoundIterator struct {
|
type PrefixBoundIterator struct {
|
||||||
trie.NodeIterator
|
trie.NodeIterator
|
||||||
EndPath []byte
|
EndPath []byte
|
||||||
@ -45,7 +46,7 @@ func (it *PrefixBoundIterator) Next(descend bool) bool {
|
|||||||
return (it.EndPath == nil) || bytes.Compare(it.Path(), it.EndPath) < 0
|
return (it.EndPath == nil) || bytes.Compare(it.Path(), it.EndPath) < 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterator with an upper bound value (hex path prefix)
|
// NewPrefixBoundIterator returns a PrefixBoundIterator with bounds [from, to)
|
||||||
func NewPrefixBoundIterator(tree state.Trie, from, to []byte) *PrefixBoundIterator {
|
func NewPrefixBoundIterator(tree state.Trie, from, to []byte) *PrefixBoundIterator {
|
||||||
it := tree.NodeIterator(nil)
|
it := tree.NodeIterator(nil)
|
||||||
for it.Next(true) {
|
for it.Next(true) {
|
||||||
@ -56,6 +57,7 @@ func NewPrefixBoundIterator(tree state.Trie, from, to []byte) *PrefixBoundIterat
|
|||||||
return &PrefixBoundIterator{NodeIterator: it, EndPath: to}
|
return &PrefixBoundIterator{NodeIterator: it, EndPath: to}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// generates nibble slice prefixes at uniform intervals
|
||||||
type prefixGenerator struct {
|
type prefixGenerator struct {
|
||||||
current []byte
|
current []byte
|
||||||
step byte
|
step byte
|
||||||
|
Loading…
Reference in New Issue
Block a user