(ctx context.Context, p path.Path, opts ...caopts.RoutingFindProvidersOption)
| 89 | } |
| 90 | |
| 91 | func (api *RoutingAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopts.RoutingFindProvidersOption) (<-chan peer.AddrInfo, error) { |
| 92 | ctx, span := tracing.Span(ctx, "CoreAPI.DhtAPI", "FindProviders", trace.WithAttributes(attribute.String("path", p.String()))) |
| 93 | defer span.End() |
| 94 | |
| 95 | settings, err := caopts.RoutingFindProvidersOptions(opts...) |
| 96 | if err != nil { |
| 97 | return nil, err |
| 98 | } |
| 99 | span.SetAttributes(attribute.Int("numproviders", settings.NumProviders)) |
| 100 | |
| 101 | err = api.checkOnline(false) |
| 102 | if err != nil { |
| 103 | return nil, err |
| 104 | } |
| 105 | |
| 106 | rp, _, err := api.core().ResolvePath(ctx, p) |
| 107 | if err != nil { |
| 108 | return nil, err |
| 109 | } |
| 110 | |
| 111 | numProviders := settings.NumProviders |
| 112 | if numProviders < 1 { |
| 113 | return nil, errors.New("number of providers must be greater than 0") |
| 114 | } |
| 115 | |
| 116 | pchan := api.routing.FindProvidersAsync(ctx, rp.RootCid(), numProviders) |
| 117 | return pchan, nil |
| 118 | } |
| 119 | |
| 120 | func (api *RoutingAPI) Provide(ctx context.Context, path path.Path, opts ...caopts.RoutingProvideOption) error { |
| 121 | ctx, span := tracing.Span(ctx, "CoreAPI.DhtAPI", "Provide", trace.WithAttributes(attribute.String("path", path.String()))) |
nothing calls this directly
no test coverage detected