2020-08-22 14:17:03 +00:00
|
|
|
package accounting
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/ecdsa"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/v2/accounting"
|
2020-08-24 10:05:10 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/services/util"
|
2020-08-22 14:17:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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-22 14:17:03 +00:00
|
|
|
}
|
|
|
|
|
2021-03-15 10:53:08 +00:00
|
|
|
func NewSignService(key *ecdsa.PrivateKey, svc Server) Server {
|
2020-08-22 14:17:03 +00:00
|
|
|
return &signService{
|
2020-08-26 09:43:39 +00:00
|
|
|
sigSvc: util.NewUnarySignService(key),
|
|
|
|
svc: svc,
|
2020-08-22 14:17:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *signService) Balance(ctx context.Context, req *accounting.BalanceRequest) (*accounting.BalanceResponse, 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.Balance(ctx, req.(*accounting.BalanceRequest))
|
|
|
|
},
|
|
|
|
)
|
2020-08-22 14:17:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-08-24 10:05:10 +00:00
|
|
|
return resp.(*accounting.BalanceResponse), nil
|
2020-08-22 14:17:03 +00:00
|
|
|
}
|