p2p/enode: add more documentation on AsyncFilter

This commit is contained in:
Felix Lange 2025-06-04 16:37:07 +02:00
parent 54f52bd604
commit 2da18aaeae

View file

@ -172,6 +172,9 @@ type asyncFilterIter struct {
type AsyncFilterFunc func(context.Context, *Node) *Node type AsyncFilterFunc func(context.Context, *Node) *Node
// AsyncFilter creates an iterator which checks nodes in parallel. // AsyncFilter creates an iterator which checks nodes in parallel.
// The 'check' function is called on multiple goroutines to filter each node
// from the upstream iterator. When check returns nil, the node will be skipped.
// It can also return a new node to be returned by the iterator instead of the .
func AsyncFilter(it Iterator, check AsyncFilterFunc, workers int) Iterator { func AsyncFilter(it Iterator, check AsyncFilterFunc, workers int) Iterator {
f := &asyncFilterIter{ f := &asyncFilterIter{
it: ensureSourceIter(it), it: ensureSourceIter(it),