2021-03-24 09:55:07 +00:00
|
|
|
package reputationrpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-api-go/v2/reputation"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/services/util"
|
2021-03-24 09:55:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(reputation.AnnounceLocalTrustResponse)
|
|
|
|
},
|
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
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(reputation.AnnounceIntermediateResultResponse)
|
|
|
|
},
|
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
|
|
|
}
|