frostfs-node/pkg/network/transport/reputation/grpc/service.go
Alex Vanin 7cf48d4d91 [#452] Update neo-go to latest master
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2021-04-06 10:35:20 +03:00

52 lines
1.5 KiB
Go

package grpcreputation
import (
"context"
"github.com/nspcc-dev/neofs-api-go/v2/reputation"
reputation2 "github.com/nspcc-dev/neofs-api-go/v2/reputation/grpc"
reputationrpc "github.com/nspcc-dev/neofs-node/pkg/services/reputation/rpc"
)
// Server wraps NeoFS API v2 Container service server
// and provides gRPC Container service server interface.
type Server struct {
srv reputationrpc.Server
}
// New creates, initializes and returns Server instance.
func New(srv reputationrpc.Server) *Server {
return &Server{
srv: srv,
}
}
func (s *Server) SendLocalTrust(ctx context.Context, r *reputation2.SendLocalTrustRequest) (*reputation2.SendLocalTrustResponse, error) {
req := new(reputation.SendLocalTrustRequest)
if err := req.FromGRPCMessage(r); err != nil {
return nil, err
}
resp, err := s.srv.SendLocalTrust(ctx, req)
if err != nil {
// TODO: think about how we transport errors through gRPC
return nil, err
}
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
}