doc
This commit is contained in:
parent
d82b49b8ba
commit
a3595be72b
@ -119,8 +119,9 @@ func (gen *prefixGenerator) Next() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates ordered cartesian product of all nibbles of given length, w/ optional prefix
|
// Generates paths that cut the trie domain into "nbins" bins, w/ optional prefix
|
||||||
// eg. MakePaths([4], 2) => [[4 0 0] [4 0 1] ... [4 f f]]
|
// eg. MakePaths([], 2) => [[0] [8]]
|
||||||
|
// MakePaths([4], 32) => [[4 0 0] [4 0 8] [4 1 0]... [4 f 8]]
|
||||||
func MakePaths(prefix []byte, nbins uint) [][]byte {
|
func MakePaths(prefix []byte, nbins uint) [][]byte {
|
||||||
var res [][]byte
|
var res [][]byte
|
||||||
for it := newPrefixGenerator(nbins); it.HasNext(); it.Next() {
|
for it := newPrefixGenerator(nbins); it.HasNext(); it.Next() {
|
||||||
@ -132,7 +133,7 @@ func MakePaths(prefix []byte, nbins uint) [][]byte {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply a function to 16^cutdepth subtries divided by path prefix
|
// Apply a function to nbins subtries divided according to path prefix
|
||||||
func VisitSubtries(tree state.Trie, nbins uint, callback func(NodeIterator)) {
|
func VisitSubtries(tree state.Trie, nbins uint, callback func(NodeIterator)) {
|
||||||
prefixes := MakePaths(nil, nbins)
|
prefixes := MakePaths(nil, nbins)
|
||||||
// pre- and postpend nil to include root & tail
|
// pre- and postpend nil to include root & tail
|
||||||
|
Loading…
Reference in New Issue
Block a user