diff --git a/p2p/discovery/routing/routing.go b/p2p/discovery/routing/routing.go index 6fee75096e..e550bc304f 100644 --- a/p2p/discovery/routing/routing.go +++ b/p2p/discovery/routing/routing.go @@ -56,23 +56,20 @@ func (d *RoutingDiscovery) Advertise(ctx context.Context, ns string, opts ...dis } func (d *RoutingDiscovery) FindPeers(ctx context.Context, ns string, opts ...discovery.Option) (<-chan peer.AddrInfo, error) { - var options discovery.Options + options := discovery.Options{ + Limit: 100, // default limit if not specified in 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 + return d.FindProvidersAsync(ctx, cid, options.Limit), nil } func nsToCid(ns string) (cid.Cid, error) {