Skip to content

Commit 2a101fa

Browse files
authored
Merge pull request #1 from vulcanize/node_sink_and_selector_suffixes
Node sink and selector suffixes support
2 parents ecc4261 + 008f534 commit 2a101fa

File tree

3 files changed

+575
-4
lines changed

3 files changed

+575
-4
lines changed

amt.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,19 @@ func (r *Root) ForEachAt(ctx context.Context, start uint64, cb func(uint64, *cbg
321321
return r.node.forEachAt(ctx, r.store, r.bitWidth, r.height, start, 0, cb)
322322
}
323323

324+
// ForEachTrackedWithNodeSink iterates over the entire AMT and calls the cb function for each
325+
// entry found in the leaf nodes. The callback will receive the index and the
326+
// value of each element.
327+
func (r *Root) ForEachTrackedWithNodeSink(ctx context.Context, b *bytes.Buffer, sink cbg.CBORUnmarshaler, cb func(uint64, *cbg.Deferred, []int) error) error {
328+
return r.node.forEachAtTrackedWithNodeSink(ctx, r.store, []int{}, r.bitWidth, r.height, 0, 0, b, sink, cb)
329+
}
330+
331+
// ForEachAtTrackedWithNodeSink iterates over the AMT beginning from the given start index. See
332+
// ForEach for more details.
333+
func (r *Root) ForEachAtTrackedWithNodeSink(ctx context.Context, start uint64, b *bytes.Buffer, sink cbg.CBORUnmarshaler, cb func(uint64, *cbg.Deferred, []int) error) error {
334+
return r.node.forEachAtTrackedWithNodeSink(ctx, r.store, []int{}, r.bitWidth, r.height, start, 0, b, sink, cb)
335+
}
336+
324337
// FirstSetIndex finds the lowest index in this AMT that has a value set for
325338
// it. If this operation is called on an empty AMT, an ErrNoValues will be
326339
// returned.

0 commit comments

Comments
 (0)