[#482] reputation/router: Move router to ./common

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-04-17 22:17:30 +03:00 committed by Pavel Karpy
parent ac8441b718
commit 477682adb7
10 changed files with 22 additions and 22 deletions

View file

@ -21,9 +21,9 @@ import (
grpcreputation "github.com/nspcc-dev/neofs-node/pkg/network/transport/reputation/grpc" grpcreputation "github.com/nspcc-dev/neofs-node/pkg/network/transport/reputation/grpc"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation"
reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
reputationrouter "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router"
trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller" trustcontroller "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/controller"
reputationroute "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/route" "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/managers"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/route/managers"
truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage" truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage"
reputationrpc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/rpc" reputationrpc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/rpc"
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"
@ -144,7 +144,7 @@ func (rtwp *remoteLocalTrustWriterProvider) InitWriter(ctx reputationcommon.Cont
}, nil }, nil
} }
func (rtp *remoteLocalTrustProvider) InitRemote(srv reputationroute.ServerInfo) (reputationcommon.WriterProvider, error) { func (rtp *remoteLocalTrustProvider) InitRemote(srv reputationrouter.ServerInfo) (reputationcommon.WriterProvider, error) {
if srv == nil { if srv == nil {
return rtp.deadEndProvider, nil return rtp.deadEndProvider, nil
} }
@ -174,7 +174,7 @@ func (rtp *remoteLocalTrustProvider) InitRemote(srv reputationroute.ServerInfo)
// BuildManagers sorts nodes in NetMap with HRW algorithms and // BuildManagers sorts nodes in NetMap with HRW algorithms and
// takes the next node after the current one as the only manager. // takes the next node after the current one as the only manager.
func (mb *managerBuilder) BuildManagers(epoch uint64, p reputation.PeerID) ([]reputationroute.ServerInfo, error) { func (mb *managerBuilder) BuildManagers(epoch uint64, p reputation.PeerID) ([]reputationrouter.ServerInfo, error) {
nm, err := mb.nmSrc.GetNetMapByEpoch(epoch) nm, err := mb.nmSrc.GetNetMapByEpoch(epoch)
if err != nil { if err != nil {
return nil, err return nil, err
@ -195,7 +195,7 @@ func (mb *managerBuilder) BuildManagers(epoch uint64, p reputation.PeerID) ([]re
managerIndex = 0 managerIndex = 0
} }
return []reputationroute.ServerInfo{nodes[managerIndex]}, nil return []reputationrouter.ServerInfo{nodes[managerIndex]}, nil
} }
} }
@ -298,8 +298,8 @@ func initReputationService(c *cfg) {
key: c.key, key: c.key,
} }
router := reputationroute.New( router := reputationrouter.New(
reputationroute.Prm{ reputationrouter.Prm{
LocalServerInfo: c, LocalServerInfo: c,
RemoteWriterProvider: remoteLocalTrustProvider, RemoteWriterProvider: remoteLocalTrustProvider,
Builder: routeBuilder, Builder: routeBuilder,
@ -364,7 +364,7 @@ type reputationServer struct {
*cfg *cfg
log *logger.Logger log *logger.Logger
router reputationcommon.WriterProvider router reputationcommon.WriterProvider
routeBuilder reputationroute.Builder routeBuilder reputationrouter.Builder
} }
type epochContext struct { type epochContext struct {
@ -389,7 +389,7 @@ func (*reputationOnlyKeyRemoteServerInfo) Address() string {
} }
func (s *reputationServer) SendLocalTrust(ctx context.Context, req *v2reputation.SendLocalTrustRequest) (*v2reputation.SendLocalTrustResponse, error) { func (s *reputationServer) SendLocalTrust(ctx context.Context, req *v2reputation.SendLocalTrustRequest) (*v2reputation.SendLocalTrustResponse, error) {
var passedRoute []reputationroute.ServerInfo var passedRoute []reputationrouter.ServerInfo
for hdr := req.GetVerificationHeader(); hdr != nil; hdr = hdr.GetOrigin() { for hdr := req.GetVerificationHeader(); hdr != nil; hdr = hdr.GetOrigin() {
passedRoute = append(passedRoute, &reputationOnlyKeyRemoteServerInfo{ passedRoute = append(passedRoute, &reputationOnlyKeyRemoteServerInfo{
@ -410,7 +410,7 @@ func (s *reputationServer) SendLocalTrust(ctx context.Context, req *v2reputation
epoch: body.GetEpoch(), epoch: body.GetEpoch(),
} }
w, err := s.router.InitWriter(reputationroute.NewRouteContext(eCtx, passedRoute)) w, err := s.router.InitWriter(reputationrouter.NewRouteContext(eCtx, passedRoute))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not initialize local trust writer") return nil, errors.Wrap(err, "could not initialize local trust writer")
} }
@ -448,8 +448,8 @@ func apiToLocalTrust(t *v2reputation.Trust, trustingPeer []byte) reputation.Trus
} }
func (s *reputationServer) processTrust(epoch uint64, t reputation.Trust, func (s *reputationServer) processTrust(epoch uint64, t reputation.Trust,
passedRoute []reputationroute.ServerInfo, w reputationcommon.Writer) error { passedRoute []reputationrouter.ServerInfo, w reputationcommon.Writer) error {
err := reputationroute.CheckRoute(s.routeBuilder, epoch, t, passedRoute) err := reputationrouter.CheckRoute(s.routeBuilder, epoch, t, passedRoute)
if err != nil { if err != nil {
return errors.Wrap(err, "wrong route of reputation trust value") return errors.Wrap(err, "wrong route of reputation trust value")
} }

View file

@ -1,4 +1,4 @@
package reputationroute package router
import ( import (
"sync" "sync"

View file

@ -1,4 +1,4 @@
package reputationroute package router
import ( import (
"github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation"

View file

@ -1,4 +1,4 @@
package reputationroute package router
import ( import (
"github.com/nspcc-dev/neofs-node/pkg/util/logger" "github.com/nspcc-dev/neofs-node/pkg/util/logger"

View file

@ -1,4 +1,4 @@
package reputationroute package router
import ( import (
"fmt" "fmt"

View file

@ -1,4 +1,4 @@
package reputationroute package router
import ( import (
"bytes" "bytes"

View file

@ -5,7 +5,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/common" reputationcommon "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common"
) )
// Prm groups the required parameters of the Controller's constructor. // Prm groups the required parameters of the Controller's constructor.
@ -24,7 +24,7 @@ type Prm struct {
// trust to other nodes. // trust to other nodes.
// //
// Must not be nil. // Must not be nil.
LocalTrustTarget common.WriterProvider LocalTrustTarget reputationcommon.WriterProvider
} }
// Controller represents main handler for starting // Controller represents main handler for starting

View file

@ -2,7 +2,7 @@ package managers
import ( import (
"github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation"
reputationroute "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/route" reputationroute "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router"
"github.com/pkg/errors" "github.com/pkg/errors"
) )

View file

@ -2,7 +2,7 @@ package managers
import ( import (
"github.com/nspcc-dev/neofs-node/pkg/services/reputation" "github.com/nspcc-dev/neofs-node/pkg/services/reputation"
reputationroute "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/route" reputationrouter "github.com/nspcc-dev/neofs-node/pkg/services/reputation/common/router"
) )
// ManagerBuilder defines an interface for providing a list // ManagerBuilder defines an interface for providing a list
@ -10,5 +10,5 @@ import (
type ManagerBuilder interface { type ManagerBuilder interface {
// BuildManagers must compose list of managers. It depends on // BuildManagers must compose list of managers. It depends on
// particular epoch and PeerID of the current route point. // particular epoch and PeerID of the current route point.
BuildManagers(epoch uint64, p reputation.PeerID) ([]reputationroute.ServerInfo, error) BuildManagers(epoch uint64, p reputation.PeerID) ([]reputationrouter.ServerInfo, error)
} }