2021-03-24 09:55:07 +00:00
|
|
|
package reputationrpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation"
|
|
|
|
"git.frostfs.info/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) {
|
2022-12-30 15:26:43 +00:00
|
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
|
|
resp := new(reputation.AnnounceLocalTrustResponse)
|
2022-12-30 17:01:13 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(util.IsStatusSupported(req), resp, err)
|
2021-03-24 09:55:07 +00:00
|
|
|
}
|
2022-12-30 15:26:43 +00:00
|
|
|
resp, err := util.WrapResponse(s.svc.AnnounceLocalTrust(ctx, req))
|
2022-12-30 17:01:13 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(util.IsStatusSupported(req), resp, err)
|
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) {
|
2022-12-30 15:26:43 +00:00
|
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
|
|
resp := new(reputation.AnnounceIntermediateResultResponse)
|
2022-12-30 17:01:13 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(util.IsStatusSupported(req), resp, err)
|
2021-04-05 09:27:58 +00:00
|
|
|
}
|
2022-12-30 15:26:43 +00:00
|
|
|
resp, err := util.WrapResponse(s.svc.AnnounceIntermediateResult(ctx, req))
|
2022-12-30 17:01:13 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(util.IsStatusSupported(req), resp, err)
|
2021-04-05 09:27:58 +00:00
|
|
|
}
|