diff --git a/cmd/neofs-node/reputation/common/managers.go b/cmd/neofs-node/reputation/common/managers.go index ef06f249ec..bec46897ea 100644 --- a/cmd/neofs-node/reputation/common/managers.go +++ b/cmd/neofs-node/reputation/common/managers.go @@ -8,7 +8,6 @@ import ( netmapcore "github.com/nspcc-dev/neofs-node/pkg/core/netmap" "github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" - reputationrouter "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router" "github.com/nspcc-dev/neofs-node/pkg/util/logger" "go.uber.org/zap" ) @@ -56,7 +55,7 @@ func NewManagerBuilder(prm ManagersPrm, opts ...MngOption) common.ManagerBuilder // BuildManagers sorts nodes in NetMap with HRW algorithms and // takes the next node after the current one as the only manager. -func (mb *managerBuilder) BuildManagers(epoch uint64, p reputation.PeerID) ([]reputationrouter.ServerInfo, error) { +func (mb *managerBuilder) BuildManagers(epoch uint64, p reputation.PeerID) ([]common.ServerInfo, error) { nm, err := mb.nmSrc.GetNetMapByEpoch(epoch) if err != nil { return nil, err @@ -77,7 +76,7 @@ func (mb *managerBuilder) BuildManagers(epoch uint64, p reputation.PeerID) ([]re managerIndex = 0 } - return []reputationrouter.ServerInfo{nodes[managerIndex]}, nil + return []common.ServerInfo{nodes[managerIndex]}, nil } } diff --git a/pkg/services/reputation/common/deps.go b/pkg/services/reputation/common/deps.go index e70589d0c5..fa2dcb61f8 100644 --- a/pkg/services/reputation/common/deps.go +++ b/pkg/services/reputation/common/deps.go @@ -5,7 +5,6 @@ import ( "io" "github.com/nspcc-dev/neofs-node/pkg/services/reputation" - "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router" ) // Context wraps stdlib context @@ -60,5 +59,19 @@ type WriterProvider interface { type ManagerBuilder interface { // BuildManagers must compose list of managers. It depends on // particular epoch and PeerID of the current route point. - BuildManagers(epoch uint64, p reputation.PeerID) ([]router.ServerInfo, error) + BuildManagers(epoch uint64, p reputation.PeerID) ([]ServerInfo, error) +} + +// ServerInfo describes a set of +// characteristics of a point in a route. +type ServerInfo interface { + // PublicKey returns public key of the node + // from the route in a binary representation. + PublicKey() []byte + + // Returns network address of the node + // in the route. + // + // Can be empty. + Address() string } diff --git a/pkg/services/reputation/common/router/calls.go b/pkg/services/reputation/common/router/calls.go index 8e3ee2847c..bd0cb521da 100644 --- a/pkg/services/reputation/common/router/calls.go +++ b/pkg/services/reputation/common/router/calls.go @@ -11,11 +11,11 @@ import ( type routeContext struct { common.Context - passedRoute []ServerInfo + passedRoute []common.ServerInfo } // NewRouteContext wraps the main context of value passing with its traversal route and epoch. -func NewRouteContext(ctx common.Context, passed []ServerInfo) common.Context { +func NewRouteContext(ctx common.Context, passed []common.ServerInfo) common.Context { return &routeContext{ Context: ctx, passedRoute: passed, @@ -54,7 +54,7 @@ func (r *Router) InitWriter(ctx common.Context) (common.Writer, error) { if routeCtx, ok = ctx.(*routeContext); !ok { routeCtx = &routeContext{ Context: ctx, - passedRoute: []ServerInfo{r.localSrvInfo}, + passedRoute: []common.ServerInfo{r.localSrvInfo}, } } @@ -73,7 +73,7 @@ func (w *trustWriter) Write(ctx common.Context, t reputation.Trust) error { if err != nil { return err } else if len(route) == 0 { - route = []ServerInfo{nil} + route = []common.ServerInfo{nil} } for _, remoteInfo := range route { diff --git a/pkg/services/reputation/common/router/deps.go b/pkg/services/reputation/common/router/deps.go index 8c2bc36d49..5d1f1290a9 100644 --- a/pkg/services/reputation/common/router/deps.go +++ b/pkg/services/reputation/common/router/deps.go @@ -5,20 +5,6 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" ) -// ServerInfo describes a set of -// characteristics of a point in a route. -type ServerInfo interface { - // PublicKey returns public key of the node - // from the route in a binary representation. - PublicKey() []byte - - // Returns network address of the node - // in the route. - // - // Can be empty. - Address() string -} - // Builder groups methods to route values in the network. type Builder interface { // NextStage must return next group of route points @@ -28,7 +14,7 @@ type Builder interface { // Empty passed list means being at the starting point of the route. // // Must return empty list and no error if the endpoint of the route is reached. - NextStage(epoch uint64, t reputation.Trust, passed []ServerInfo) ([]ServerInfo, error) + NextStage(epoch uint64, t reputation.Trust, passed []common.ServerInfo) ([]common.ServerInfo, error) } // RemoteWriterProvider describes the component @@ -38,5 +24,5 @@ type RemoteWriterProvider interface { // corresponding to info. // // Nil info matches the end of the route. - InitRemote(info ServerInfo) (common.WriterProvider, error) + InitRemote(info common.ServerInfo) (common.WriterProvider, error) } diff --git a/pkg/services/reputation/common/router/router.go b/pkg/services/reputation/common/router/router.go index b5fe634c9f..883631964c 100644 --- a/pkg/services/reputation/common/router/router.go +++ b/pkg/services/reputation/common/router/router.go @@ -3,6 +3,7 @@ package router import ( "fmt" + "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" "github.com/nspcc-dev/neofs-node/pkg/util/logger" ) @@ -15,7 +16,7 @@ type Prm struct { // Characteristics of the local node's server. // // Must not be nil. - LocalServerInfo ServerInfo + LocalServerInfo common.ServerInfo // Component for sending values to a fixed route point. // @@ -46,7 +47,7 @@ type Router struct { routeBuilder Builder - localSrvInfo ServerInfo + localSrvInfo common.ServerInfo } const invalidPrmValFmt = "invalid parameter %s (%T):%v" diff --git a/pkg/services/reputation/common/router/util.go b/pkg/services/reputation/common/router/util.go index 77c92b7f3e..d43745c26b 100644 --- a/pkg/services/reputation/common/router/util.go +++ b/pkg/services/reputation/common/router/util.go @@ -5,6 +5,7 @@ import ( "errors" "github.com/nspcc-dev/neofs-node/pkg/services/reputation" + "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" ) var errWrongRoute = errors.New("wrong route") @@ -12,7 +13,7 @@ var errWrongRoute = errors.New("wrong route") // CheckRoute checks if the route is a route correctly constructed by the builder for value a. // // Returns nil if route is correct, otherwise an error clarifying the inconsistency. -func CheckRoute(builder Builder, epoch uint64, t reputation.Trust, route []ServerInfo) error { +func CheckRoute(builder Builder, epoch uint64, t reputation.Trust, route []common.ServerInfo) error { for i := 1; i < len(route); i++ { servers, err := builder.NextStage(epoch, t, route[:i]) if err != nil { diff --git a/pkg/services/reputation/eigentrust/routes/calls.go b/pkg/services/reputation/eigentrust/routes/calls.go index c7f3f07e08..b46f33c921 100644 --- a/pkg/services/reputation/eigentrust/routes/calls.go +++ b/pkg/services/reputation/eigentrust/routes/calls.go @@ -2,14 +2,14 @@ package routes import ( "github.com/nspcc-dev/neofs-node/pkg/services/reputation" - reputationroute "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router" + "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" "github.com/pkg/errors" ) // NextStage builds Manager list for trusted node and returns it directly. // // If passed route has more than one point, then endpoint of the route is reached. -func (b *Builder) NextStage(epoch uint64, t reputation.Trust, passed []reputationroute.ServerInfo) ([]reputationroute.ServerInfo, error) { +func (b *Builder) NextStage(epoch uint64, t reputation.Trust, passed []common.ServerInfo) ([]common.ServerInfo, error) { if len(passed) > 1 { return nil, nil } diff --git a/pkg/services/reputation/local/routes/calls.go b/pkg/services/reputation/local/routes/calls.go index 21dce72646..8713b53fb6 100644 --- a/pkg/services/reputation/local/routes/calls.go +++ b/pkg/services/reputation/local/routes/calls.go @@ -2,14 +2,14 @@ package routes import ( "github.com/nspcc-dev/neofs-node/pkg/services/reputation" - reputationroute "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router" + "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" "github.com/pkg/errors" ) // NextStage builds Manager list for trusting node and returns it directly. // // If passed route has more than one point, then endpoint of the route is reached. -func (b *Builder) NextStage(epoch uint64, t reputation.Trust, passed []reputationroute.ServerInfo) ([]reputationroute.ServerInfo, error) { +func (b *Builder) NextStage(epoch uint64, t reputation.Trust, passed []common.ServerInfo) ([]common.ServerInfo, error) { if len(passed) > 1 { return nil, nil }