2020-08-24 14:54:48 +00:00
|
|
|
package session
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/util"
|
|
|
|
)
|
|
|
|
|
|
|
|
type signService struct {
|
2020-08-26 09:43:39 +00:00
|
|
|
sigSvc *util.SignService
|
2020-08-26 09:20:26 +00:00
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
svc Server
|
2020-08-24 14:54:48 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
|
2020-08-24 14:54:48 +00:00
|
|
|
return &signService{
|
2020-08-26 09:43:39 +00:00
|
|
|
sigSvc: util.NewUnarySignService(key),
|
2020-09-21 09:33:55 +00:00
|
|
|
svc: svc,
|
2020-08-24 14:54:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) Create(ctx context.Context, req *session.CreateRequest) (*session.CreateResponse, error) {
|
2020-08-26 09:43:39 +00:00
|
|
|
resp, err := s.sigSvc.HandleUnaryRequest(ctx, req,
|
2020-10-22 08:03:34 +00:00
|
|
|
func(ctx context.Context, req interface{}) (util.ResponseMessage, error) {
|
2020-08-26 09:20:26 +00:00
|
|
|
return s.svc.Create(ctx, req.(*session.CreateRequest))
|
|
|
|
},
|
2021-11-06 11:13:04 +00:00
|
|
|
func() util.ResponseMessage {
|
|
|
|
return new(session.CreateResponse)
|
|
|
|
},
|
2020-08-26 09:20:26 +00:00
|
|
|
)
|
2020-08-24 14:54:48 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return resp.(*session.CreateResponse), nil
|
|
|
|
}
|