frostfs-node/pkg/services/reputation/rpc/sign.go
Evgenii Stratonikov cfd1b1d349 [#6] services/util: Remove remaining stream wrappers
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2023-03-21 13:03:03 +03:00

40 lines
1.4 KiB
Go

package reputationrpc
import (
"context"
"crypto/ecdsa"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/reputation"
"git.frostfs.info/TrueCloudLab/frostfs-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,
}
}
func (s *signService) AnnounceLocalTrust(ctx context.Context, req *reputation.AnnounceLocalTrustRequest) (*reputation.AnnounceLocalTrustResponse, error) {
if err := s.sigSvc.VerifyRequest(req); err != nil {
resp := new(reputation.AnnounceLocalTrustResponse)
return resp, s.sigSvc.SignResponse(util.IsStatusSupported(req), resp, err)
}
resp, err := util.WrapResponse(s.svc.AnnounceLocalTrust(ctx, req))
return resp, s.sigSvc.SignResponse(util.IsStatusSupported(req), resp, err)
}
func (s *signService) AnnounceIntermediateResult(ctx context.Context, req *reputation.AnnounceIntermediateResultRequest) (*reputation.AnnounceIntermediateResultResponse, error) {
if err := s.sigSvc.VerifyRequest(req); err != nil {
resp := new(reputation.AnnounceIntermediateResultResponse)
return resp, s.sigSvc.SignResponse(util.IsStatusSupported(req), resp, err)
}
resp, err := util.WrapResponse(s.svc.AnnounceIntermediateResult(ctx, req))
return resp, s.sigSvc.SignResponse(util.IsStatusSupported(req), resp, err)
}