2021-03-24 09:55:07 +00:00
|
|
|
package reputationrpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/reputation"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
type signService struct {
|
|
|
|
sigSvc *util.SignService
|
|
|
|
|
|
|
|
svc Server
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
|
|
|
|
return &signService{
|
|
|
|
sigSvc: util.NewUnarySignService(key),
|
|
|
|
svc: svc,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-07 11:13:11 +00:00
|
|
|
func (s *signService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) {
|
2021-03-24 09:55:07 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
|
|
|
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
|
2021-05-07 11:13:11 +00:00
|
|
|
return s.svc.AnnounceLocalTrust(ctx, req.(*reputation.AnnounceLocalTrustRequest))
|
2021-03-24 09:55:07 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-05-07 11:13:11 +00:00
|
|
|
return resp.(*reputation.AnnounceLocalTrustResponse), nil
|
2021-03-24 09:55:07 +00:00
|
|
|
}
|
2021-04-05 09:27:58 +00:00
|
|
|
|
2021-05-07 11:13:11 +00:00
|
|
|
func (s *signService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) {
|
2021-04-05 09:27:58 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
|
|
|
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
|
2021-05-07 11:13:11 +00:00
|
|
|
return s.svc.AnnounceIntermediateResult(ctx, req.(*reputation.AnnounceIntermediateResultRequest))
|
2021-04-05 09:27:58 +00:00
|
|
|
},
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-05-07 11:13:11 +00:00
|
|
|
return resp.(*reputation.AnnounceIntermediateResultResponse), nil
|
2021-04-05 09:27:58 +00:00
|
|
|
}
|