Skip to content

Commit

Permalink
style: add nolint to deprecated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Jan 31, 2024
1 parent b8a06d5 commit 7a297b2
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions client/rpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions client/rpc/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
1 change: 1 addition & 0 deletions core/coreapi/coreapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions core/coreapi/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down
8 changes: 4 additions & 4 deletions core/coreapi/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions core/coreiface/coreapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type CoreAPI interface {
// Object returns an implementation of Object API
Object() ObjectAPI

// nolint deprecated
// Deprecated: use [Routing] instead.
Dht() DhtAPI

Expand Down
4 changes: 4 additions & 0 deletions core/coreiface/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 7 additions & 0 deletions core/coreiface/options/dht.go
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions core/coreiface/options/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func RoutingPutOptions(opts ...RoutingPutOption) (*RoutingPutSettings, error) {
return options, nil
}

// nolint deprecated
// Deprecated: use [Routing] instead.
var Put = Routing

Expand Down
4 changes: 2 additions & 2 deletions core/coreiface/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 7a297b2

Please sign in to comment.