2020-10-08 13:14:19 +00:00
|
|
|
package netmap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/util"
|
2024-11-07 14:32:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/netmap"
|
2020-10-08 13:14:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type signService struct {
|
|
|
|
sigSvc *util.SignService
|
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
svc Server
|
2020-10-08 13:14:19 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
|
2020-10-08 13:14:19 +00:00
|
|
|
return &signService{
|
|
|
|
sigSvc: util.NewUnarySignService(key),
|
|
|
|
svc: svc,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) LocalNodeInfo(
|
|
|
|
ctx context.Context,
|
2023-10-31 11:56:55 +00:00
|
|
|
req *netmap.LocalNodeInfoRequest,
|
|
|
|
) (*netmap.LocalNodeInfoResponse, error) {
|
2022-12-30 15:26:43 +00:00
|
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
|
|
resp := new(netmap.LocalNodeInfoResponse)
|
2023-07-26 12:47:32 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
2020-10-08 13:14:19 +00:00
|
|
|
}
|
2022-12-30 15:26:43 +00:00
|
|
|
resp, err := util.EnsureNonNilResponse(s.svc.LocalNodeInfo(ctx, req))
|
2023-07-26 12:47:32 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
2020-10-08 13:14:19 +00:00
|
|
|
}
|
2021-02-19 08:01:37 +00:00
|
|
|
|
|
|
|
func (s *signService) NetworkInfo(ctx context.Context, req *netmap.NetworkInfoRequest) (*netmap.NetworkInfoResponse, error) {
|
2022-12-30 15:26:43 +00:00
|
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
|
|
resp := new(netmap.NetworkInfoResponse)
|
2023-07-26 12:47:32 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
2021-02-19 08:01:37 +00:00
|
|
|
}
|
2022-12-30 15:26:43 +00:00
|
|
|
resp, err := util.EnsureNonNilResponse(s.svc.NetworkInfo(ctx, req))
|
2023-07-26 12:47:32 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
2021-02-19 08:01:37 +00:00
|
|
|
}
|
2022-09-17 12:37:01 +00:00
|
|
|
|
|
|
|
func (s *signService) Snapshot(ctx context.Context, req *netmap.SnapshotRequest) (*netmap.SnapshotResponse, error) {
|
2022-12-30 15:26:43 +00:00
|
|
|
if err := s.sigSvc.VerifyRequest(req); err != nil {
|
|
|
|
resp := new(netmap.SnapshotResponse)
|
2023-07-26 12:47:32 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
2022-09-17 12:37:01 +00:00
|
|
|
}
|
2022-12-30 15:26:43 +00:00
|
|
|
resp, err := util.EnsureNonNilResponse(s.svc.Snapshot(ctx, req))
|
2023-07-26 12:47:32 +00:00
|
|
|
return resp, s.sigSvc.SignResponse(resp, err)
|
2022-09-17 12:37:01 +00:00
|
|
|
}
|