diff --git a/cmd/neofs-node/reputation.go b/cmd/neofs-node/reputation.go index a65aacd3c..293ca4d8f 100644 --- a/cmd/neofs-node/reputation.go +++ b/cmd/neofs-node/reputation.go @@ -180,7 +180,7 @@ func (s *loggingReputationServer) SendLocalTrust(_ context.Context, req *v2reput for _, t := range body.GetTrusts() { log.Info("local trust received", - zap.String("peer", hex.EncodeToString(t.GetPeer())), + zap.String("peer", hex.EncodeToString(t.GetPeer().GetValue())), zap.Float64("value", t.GetValue()), ) } @@ -190,3 +190,11 @@ func (s *loggingReputationServer) SendLocalTrust(_ context.Context, req *v2reput return resp, nil } + +func (s *loggingReputationServer) SendIntermediateResult(_ context.Context, req *v2reputation.SendIntermediateResultRequest) (*v2reputation.SendIntermediateResultResponse, error) { + resp := new(v2reputation.SendIntermediateResultResponse) + + // todo: implement me + + return resp, nil +} diff --git a/go.mod b/go.mod index afa2c4390..7be2a9521 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/multiformats/go-multihash v0.0.13 // indirect github.com/nspcc-dev/hrw v1.0.9 github.com/nspcc-dev/neo-go v0.94.0 - github.com/nspcc-dev/neofs-api-go v1.25.1-0.20210325082034-b792e4e4647a + github.com/nspcc-dev/neofs-api-go v1.25.1-0.20210402125759-771f395d9d4e github.com/nspcc-dev/neofs-crypto v0.3.0 github.com/nspcc-dev/tzhash v1.4.0 github.com/panjf2000/ants/v2 v2.3.0 diff --git a/go.sum b/go.sum index f9efd0fe5..a2f93c73d 100644 Binary files a/go.sum and b/go.sum differ diff --git a/pkg/network/transport/reputation/grpc/service.go b/pkg/network/transport/reputation/grpc/service.go index 41e28fa07..8a75ef858 100644 --- a/pkg/network/transport/reputation/grpc/service.go +++ b/pkg/network/transport/reputation/grpc/service.go @@ -35,3 +35,18 @@ func (s *Server) SendLocalTrust(ctx context.Context, r *reputation2.SendLocalTru return resp.ToGRPCMessage().(*reputation2.SendLocalTrustResponse), nil } + +func (s *Server) SendIntermediateResult(ctx context.Context, r *reputation2.SendIntermediateResultRequest) (*reputation2.SendIntermediateResultResponse, error) { + req := new(reputation.SendIntermediateResultRequest) + if err := req.FromGRPCMessage(r); err != nil { + return nil, err + } + + resp, err := s.srv.SendIntermediateResult(ctx, req) + if err != nil { + // TODO: think about how we transport errors through gRPC + return nil, err + } + + return resp.ToGRPCMessage().(*reputation2.SendIntermediateResultResponse), nil +} diff --git a/pkg/services/reputation/rpc/response.go b/pkg/services/reputation/rpc/response.go index a1633cf14..805408371 100644 --- a/pkg/services/reputation/rpc/response.go +++ b/pkg/services/reputation/rpc/response.go @@ -35,3 +35,16 @@ func (s *responseService) SendLocalTrust(ctx context.Context, req *reputation.Se return resp.(*reputation.SendLocalTrustResponse), nil } + +func (s *responseService) SendIntermediateResult(ctx context.Context, req *reputation.SendIntermediateResultRequest) (*reputation.SendIntermediateResultResponse, error) { + resp, err := s.respSvc.HandleUnaryRequest(ctx, req, + func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + return s.svc.SendIntermediateResult(ctx, req.(*reputation.SendIntermediateResultRequest)) + }, + ) + if err != nil { + return nil, err + } + + return resp.(*reputation.SendIntermediateResultResponse), nil +} diff --git a/pkg/services/reputation/rpc/server.go b/pkg/services/reputation/rpc/server.go index f6ccfbfe2..4647453bf 100644 --- a/pkg/services/reputation/rpc/server.go +++ b/pkg/services/reputation/rpc/server.go @@ -9,4 +9,5 @@ import ( // Server is an interface of the NeoFS API v2 Reputation service server. type Server interface { SendLocalTrust(context.Context, *reputation.SendLocalTrustRequest) (*reputation.SendLocalTrustResponse, error) + SendIntermediateResult(context.Context, *reputation.SendIntermediateResultRequest) (*reputation.SendIntermediateResultResponse, error) } diff --git a/pkg/services/reputation/rpc/sign.go b/pkg/services/reputation/rpc/sign.go index 4903a33dc..d44f2a1f0 100644 --- a/pkg/services/reputation/rpc/sign.go +++ b/pkg/services/reputation/rpc/sign.go @@ -33,3 +33,16 @@ func (s *signService) SendLocalTrust(ctx context.Context, req *reputation.SendLo return resp.(*reputation.SendLocalTrustResponse), nil } + +func (s *signService) SendIntermediateResult(ctx context.Context, req *reputation.SendIntermediateResultRequest) (*reputation.SendIntermediateResultResponse, error) { + resp, err := s.sigSvc.HandleUnaryRequest(ctx, req, + func(ctx context.Context, req interface{}) (util.ResponseMessage, error) { + return s.svc.SendIntermediateResult(ctx, req.(*reputation.SendIntermediateResultRequest)) + }, + ) + if err != nil { + return nil, err + } + + return resp.(*reputation.SendIntermediateResultResponse), nil +}