frostfs-node/pkg/services/netmap/sign.go
Airat Arifullin 9b13a18aac [#1479] go.mod: Bump frostfs-sdk-go version
* Update version within go.mod;
* Fix deprecated frostfs-api-go/v2 package and use frostfs-sdk-go/api
  instead.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
2024-11-08 10:43:19 +03:00

52 lines
1.5 KiB
Go

package netmap
import (
"context"
"crypto/ecdsa"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/netmap"
)
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) LocalNodeInfo(
ctx context.Context,
req *netmap.LocalNodeInfoRequest,
) (*netmap.LocalNodeInfoResponse, error) {
if err := s.sigSvc.VerifyRequest(req); err != nil {
resp := new(netmap.LocalNodeInfoResponse)
return resp, s.sigSvc.SignResponse(resp, err)
}
resp, err := util.EnsureNonNilResponse(s.svc.LocalNodeInfo(ctx, req))
return resp, s.sigSvc.SignResponse(resp, err)
}
func (s *signService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) {
if err := s.sigSvc.VerifyRequest(req); err != nil {
resp := new(netmap.NetworkInfoResponse)
return resp, s.sigSvc.SignResponse(resp, err)
}
resp, err := util.EnsureNonNilResponse(s.svc.NetworkInfo(ctx, req))
return resp, s.sigSvc.SignResponse(resp, err)
}
func (s *signService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) {
if err := s.sigSvc.VerifyRequest(req); err != nil {
resp := new(netmap.SnapshotResponse)
return resp, s.sigSvc.SignResponse(resp, err)
}
resp, err := util.EnsureNonNilResponse(s.svc.Snapshot(ctx, req))
return resp, s.sigSvc.SignResponse(resp, err)
}