From a3595be72b83fc002aa856bf5847cb0481434a11 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Mon, 31 Aug 2020 22:22:40 -0500 Subject: [PATCH] doc --- pkg/iterator/iterator.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/iterator/iterator.go b/pkg/iterator/iterator.go index 87f7db5..850d91d 100644 --- a/pkg/iterator/iterator.go +++ b/pkg/iterator/iterator.go @@ -119,8 +119,9 @@ func (gen *prefixGenerator) Next() { } } -// Generates ordered cartesian product of all nibbles of given length, w/ optional prefix -// eg. MakePaths([4], 2) => [[4 0 0] [4 0 1] ... [4 f f]] +// Generates paths that cut the trie domain into "nbins" bins, w/ optional prefix +// 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 { var res [][]byte for it := newPrefixGenerator(nbins); it.HasNext(); it.Next() { @@ -132,7 +133,7 @@ func MakePaths(prefix []byte, nbins uint) [][]byte { 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)) { prefixes := MakePaths(nil, nbins) // pre- and postpend nil to include root & tail