forked from TrueCloudLab/frostfs-node
[#482] reputation/router: Move router to ./common
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
ac8441b718
commit
477682adb7
10 changed files with 22 additions and 22 deletions
|
@ -21,9 +21,9 @@ import (
|
|||
grpcreputation "github.com/nspcc-dev/neofs-node/pkg/network/transport/reputation/grpc"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
|
||||
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"
|
||||
reputationroute "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/route"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/route/managers"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/managers"
|
||||
truststorage "github.com/nspcc-dev/neofs-node/pkg/services/reputation/local/storage"
|
||||
reputationrpc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/rpc"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||
|
@ -144,7 +144,7 @@ func (rtwp *remoteLocalTrustWriterProvider) InitWriter(ctx reputationcommon.Cont
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (rtp *remoteLocalTrustProvider) InitRemote(srv reputationroute.ServerInfo) (reputationcommon.WriterProvider, error) {
|
||||
func (rtp *remoteLocalTrustProvider) InitRemote(srv reputationrouter.ServerInfo) (reputationcommon.WriterProvider, error) {
|
||||
if srv == 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
|
||||
// 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)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -195,7 +195,7 @@ func (mb *managerBuilder) BuildManagers(epoch uint64, p reputation.PeerID) ([]re
|
|||
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,
|
||||
}
|
||||
|
||||
router := reputationroute.New(
|
||||
reputationroute.Prm{
|
||||
router := reputationrouter.New(
|
||||
reputationrouter.Prm{
|
||||
LocalServerInfo: c,
|
||||
RemoteWriterProvider: remoteLocalTrustProvider,
|
||||
Builder: routeBuilder,
|
||||
|
@ -364,7 +364,7 @@ type reputationServer struct {
|
|||
*cfg
|
||||
log *logger.Logger
|
||||
router reputationcommon.WriterProvider
|
||||
routeBuilder reputationroute.Builder
|
||||
routeBuilder reputationrouter.Builder
|
||||
}
|
||||
|
||||
type epochContext struct {
|
||||
|
@ -389,7 +389,7 @@ func (*reputationOnlyKeyRemoteServerInfo) Address() string {
|
|||
}
|
||||
|
||||
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() {
|
||||
passedRoute = append(passedRoute, &reputationOnlyKeyRemoteServerInfo{
|
||||
|
@ -410,7 +410,7 @@ func (s *reputationServer) SendLocalTrust(ctx context.Context, req *v2reputation
|
|||
epoch: body.GetEpoch(),
|
||||
}
|
||||
|
||||
w, err := s.router.InitWriter(reputationroute.NewRouteContext(eCtx, passedRoute))
|
||||
w, err := s.router.InitWriter(reputationrouter.NewRouteContext(eCtx, passedRoute))
|
||||
if err != nil {
|
||||
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,
|
||||
passedRoute []reputationroute.ServerInfo, w reputationcommon.Writer) error {
|
||||
err := reputationroute.CheckRoute(s.routeBuilder, epoch, t, passedRoute)
|
||||
passedRoute []reputationrouter.ServerInfo, w reputationcommon.Writer) error {
|
||||
err := reputationrouter.CheckRoute(s.routeBuilder, epoch, t, passedRoute)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "wrong route of reputation trust value")
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package reputationroute
|
||||
package router
|
||||
|
||||
import (
|
||||
"sync"
|
|
@ -1,4 +1,4 @@
|
|||
package reputationroute
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/reputation"
|
|
@ -1,4 +1,4 @@
|
|||
package reputationroute
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
|
@ -1,4 +1,4 @@
|
|||
package reputationroute
|
||||
package router
|
||||
|
||||
import (
|
||||
"fmt"
|
|
@ -1,4 +1,4 @@
|
|||
package reputationroute
|
||||
package router
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"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.
|
||||
|
@ -24,7 +24,7 @@ type Prm struct {
|
|||
// trust to other nodes.
|
||||
//
|
||||
// Must not be nil.
|
||||
LocalTrustTarget common.WriterProvider
|
||||
LocalTrustTarget reputationcommon.WriterProvider
|
||||
}
|
||||
|
||||
// Controller represents main handler for starting
|
||||
|
|
|
@ -2,7 +2,7 @@ package managers
|
|||
|
||||
import (
|
||||
"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"
|
||||
)
|
||||
|
|
@ -2,7 +2,7 @@ package managers
|
|||
|
||||
import (
|
||||
"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
|
||||
|
@ -10,5 +10,5 @@ import (
|
|||
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) ([]reputationroute.ServerInfo, error)
|
||||
BuildManagers(epoch uint64, p reputation.PeerID) ([]reputationrouter.ServerInfo, error)
|
||||
}
|
Loading…
Reference in a new issue