diff --git a/client/rpc/api.go b/client/rpc/api.go index 6e3b106933c0..827b427c9fff 100644 --- a/client/rpc/api.go +++ b/client/rpc/api.go @@ -227,6 +227,7 @@ func (api *HttpApi) Object() iface.ObjectAPI { return (*ObjectAPI)(api) } +// nolint deprecated // Deprecated: use [HttpApi.Routing] instead. func (api *HttpApi) Dht() iface.DhtAPI { return (*DhtAPI)(api) diff --git a/client/rpc/dht.go b/client/rpc/dht.go index a69170843ee8..cfc886a49e6d 100644 --- a/client/rpc/dht.go +++ b/client/rpc/dht.go @@ -10,16 +10,19 @@ import ( type DhtAPI HttpApi +// nolint deprecated // Deprecated: use [RoutingAPI.FindPeer] instead. func (api *DhtAPI) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) { return api.core().Routing().FindPeer(ctx, p) } +// nolint deprecated // Deprecated: use [RoutingAPI.FindProviders] instead. func (api *DhtAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopts.DhtFindProvidersOption) (<-chan peer.AddrInfo, error) { return api.core().Routing().FindProviders(ctx, p, opts...) } +// nolint deprecated // Deprecated: use [RoutingAPI.Provide] instead. func (api *DhtAPI) Provide(ctx context.Context, p path.Path, opts ...caopts.DhtProvideOption) error { return api.core().Routing().Provide(ctx, p, opts...) diff --git a/core/coreapi/coreapi.go b/core/coreapi/coreapi.go index dda71afdc293..6c6aa4907e8e 100644 --- a/core/coreapi/coreapi.go +++ b/core/coreapi/coreapi.go @@ -130,6 +130,7 @@ func (api *CoreAPI) Pin() coreiface.PinAPI { return (*PinAPI)(api) } +// nolint deprecated // Deprecated: use [CoreAPI.Routing] instead. func (api *CoreAPI) Dht() coreiface.DhtAPI { return (*DhtAPI)(api) diff --git a/core/coreapi/dht.go b/core/coreapi/dht.go index 445c8735287b..f9155de008ef 100644 --- a/core/coreapi/dht.go +++ b/core/coreapi/dht.go @@ -11,16 +11,19 @@ import ( type DhtAPI CoreAPI +// nolint deprecated // Deprecated: use [RoutingAPI.FindPeer] instead. func (api *DhtAPI) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, error) { return api.core().Routing().FindPeer(ctx, p) } +// nolint deprecated // Deprecated: use [RoutingAPI.FindProviders] instead. func (api *DhtAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopts.DhtFindProvidersOption) (<-chan peer.AddrInfo, error) { return api.core().Routing().FindProviders(ctx, p, opts...) } +// nolint deprecated // Deprecated: use [RoutingAPI.Provide] instead. func (api *DhtAPI) Provide(ctx context.Context, p path.Path, opts ...caopts.DhtProvideOption) error { return api.core().Routing().Provide(ctx, p, opts...) diff --git a/core/coreapi/routing.go b/core/coreapi/routing.go index 906527c258ab..518249fad2b0 100644 --- a/core/coreapi/routing.go +++ b/core/coreapi/routing.go @@ -87,11 +87,11 @@ func (api *RoutingAPI) FindPeer(ctx context.Context, p peer.ID) (peer.AddrInfo, return pi, nil } -func (api *RoutingAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopts.DhtFindProvidersOption) (<-chan peer.AddrInfo, error) { +func (api *RoutingAPI) FindProviders(ctx context.Context, p path.Path, opts ...caopts.RoutingFindProvidersOption) (<-chan peer.AddrInfo, error) { ctx, span := tracing.Span(ctx, "CoreAPI.DhtAPI", "FindProviders", trace.WithAttributes(attribute.String("path", p.String()))) defer span.End() - settings, err := caopts.DhtFindProvidersOptions(opts...) + settings, err := caopts.RoutingFindProvidersOptions(opts...) if err != nil { return nil, err } @@ -116,11 +116,11 @@ func (api *RoutingAPI) FindProviders(ctx context.Context, p path.Path, opts ...c return pchan, nil } -func (api *RoutingAPI) Provide(ctx context.Context, path path.Path, opts ...caopts.DhtProvideOption) error { +func (api *RoutingAPI) Provide(ctx context.Context, path path.Path, opts ...caopts.RoutingProvideOption) error { ctx, span := tracing.Span(ctx, "CoreAPI.DhtAPI", "Provide", trace.WithAttributes(attribute.String("path", path.String()))) defer span.End() - settings, err := caopts.DhtProvideOptions(opts...) + settings, err := caopts.RoutingProvideOptions(opts...) if err != nil { return err } diff --git a/core/coreiface/coreapi.go b/core/coreiface/coreapi.go index c770bf41cd94..bcd94f3816cb 100644 --- a/core/coreiface/coreapi.go +++ b/core/coreiface/coreapi.go @@ -34,6 +34,7 @@ type CoreAPI interface { // Object returns an implementation of Object API Object() ObjectAPI + // nolint deprecated // Deprecated: use [Routing] instead. Dht() DhtAPI diff --git a/core/coreiface/dht.go b/core/coreiface/dht.go index 3147333518be..001f5856a1b2 100644 --- a/core/coreiface/dht.go +++ b/core/coreiface/dht.go @@ -8,14 +8,18 @@ import ( "github.com/libp2p/go-libp2p/core/peer" ) +// nolint deprecated // Deprecated: use [RoutingAPI] instead. type DhtAPI interface { + // nolint deprecated // Deprecated: use [RoutingAPI.FindPeer] instead. FindPeer(context.Context, peer.ID) (peer.AddrInfo, error) + // nolint deprecated // Deprecated: use [RoutingAPI.FindProviders] instead. FindProviders(context.Context, path.Path, ...options.DhtFindProvidersOption) (<-chan peer.AddrInfo, error) + // nolint deprecated // Deprecated: use [RoutingAPI.Provide] instead. Provide(context.Context, path.Path, ...options.DhtProvideOption) error } diff --git a/core/coreiface/options/dht.go b/core/coreiface/options/dht.go index 91cd255b4ffa..4a6f7f86e765 100644 --- a/core/coreiface/options/dht.go +++ b/core/coreiface/options/dht.go @@ -1,22 +1,29 @@ package options +// nolint deprecated // Deprecated: use [RoutingProvideSettings] instead. type DhtProvideSettings = RoutingProvideSettings +// nolint deprecated // Deprecated: use [RoutingFindProvidersSettings] instead. type DhtFindProvidersSettings = RoutingFindProvidersSettings +// nolint deprecated // Deprecated: use [RoutingProvideOption] instead. type DhtProvideOption = RoutingProvideOption +// nolint deprecated // Deprecated: use [RoutingFindProvidersOption] instead. type DhtFindProvidersOption = RoutingFindProvidersOption +// nolint deprecated // Deprecated: use [RoutingProvideOptions] instead. var DhtProvideOptions = RoutingProvideOptions +// nolint deprecated // Deprecated: use [RoutingFindProvidersOptions] instead. var DhtFindProvidersOptions = RoutingFindProvidersOptions +// nolint deprecated // Deprecated: use [Routing] instead. var Dht = Routing diff --git a/core/coreiface/options/routing.go b/core/coreiface/options/routing.go index c1ea5a84e6f1..8da7e7a1db22 100644 --- a/core/coreiface/options/routing.go +++ b/core/coreiface/options/routing.go @@ -21,6 +21,7 @@ func RoutingPutOptions(opts ...RoutingPutOption) (*RoutingPutSettings, error) { return options, nil } +// nolint deprecated // Deprecated: use [Routing] instead. var Put = Routing diff --git a/core/coreiface/routing.go b/core/coreiface/routing.go index b7cbe6d790b6..a17dfcad920c 100644 --- a/core/coreiface/routing.go +++ b/core/coreiface/routing.go @@ -22,8 +22,8 @@ type RoutingAPI interface { // FindProviders finds the peers in the routing system who can provide a specific // value given a key. - FindProviders(context.Context, path.Path, ...options.DhtFindProvidersOption) (<-chan peer.AddrInfo, error) + FindProviders(context.Context, path.Path, ...options.RoutingFindProvidersOption) (<-chan peer.AddrInfo, error) // Provide announces to the network that you are providing given values - Provide(context.Context, path.Path, ...options.DhtProvideOption) error + Provide(context.Context, path.Path, ...options.RoutingProvideOption) error }