Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(discovery): allow FindPeers limit to be 0 #2894

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

guillaumemichel
Copy link
Contributor

func (d *RoutingDiscovery) FindPeers(ctx context.Context, ns string, opts ...discovery.Option) (<-chan peer.AddrInfo, error) {
var options discovery.Options
err := options.Apply(opts...)
if err != nil {
return nil, err
}
limit := options.Limit
if limit == 0 {
limit = 100 // that's just arbitrary, but FindProvidersAsync needs a count
}
cid, err := nsToCid(ns)
if err != nil {
return nil, err
}
return d.FindProvidersAsync(ctx, cid, limit), nil
}

FindProvidersAsync allows a limit of 0 to return all found providers. However, it is impossible to make use of this feature with FindPeers since it sets the limit to 100 if it was previously 0.

This is a non breaking fix, users omitting the Limit(X) parameter will continue to have (at most) 100 results returned. Alternatively, we could change the default to return all found peers.

resolves #2859

@MarcoPolo MarcoPolo merged commit 46c6397 into master Jul 31, 2024
10 of 11 checks passed
@guillaumemichel guillaumemichel deleted the fix/discovery-findpeer-limit branch August 2, 2024 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

discovery: not allowing limit to be 0
2 participants