[#943] service/object: Remove KeyStore from CommonPrm

There is no point to pass key storage in parameters because
it can be defined on the service level of application.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-10-26 16:02:46 +03:00 committed by Alex Vanin
parent c30aa20b04
commit fbed86da2c
9 changed files with 40 additions and 40 deletions

View file

@ -105,7 +105,7 @@ func (exec execCtx) isChild(obj *object.Object) bool {
}
func (exec execCtx) key() (*ecdsa.PrivateKey, error) {
return exec.prm.common.KeyStorage().GetKey(exec.prm.common.SessionToken())
return exec.svc.keyStore.GetKey(exec.prm.common.SessionToken())
}
func (exec execCtx) callOptions() ([]client.CallOption, error) {

View file

@ -1,7 +1,10 @@
package getsvc
import (
"crypto/ecdsa"
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
"github.com/nspcc-dev/neofs-api-go/pkg/session"
"github.com/nspcc-dev/neofs-node/pkg/core/client"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/core/object"
@ -44,6 +47,10 @@ type cfg struct {
currentEpochReceiver interface {
currentEpoch() (uint64, error)
}
keyStore interface {
GetKey(token *session.Token) (*ecdsa.PrivateKey, error)
}
}
func defaultCfg() *cfg {
@ -119,3 +126,11 @@ func WithNetMapSource(nmSrc netmap.Source) Option {
}
}
}
// WithKeyStorage returns option to set private
// key storage for session tokens and node key.
func WithKeyStorage(store *util.KeyStorage) Option {
return func(c *cfg) {
c.keyStore = store
}
}

View file

@ -38,9 +38,7 @@ func (s *Service) toPrm(req *objectV2.GetRequest, stream objectSvc.GetObjectStre
}
p := new(getsvc.Prm)
p.SetCommonParameters(commonPrm.
WithKeyStorage(s.keyStorage),
)
p.SetCommonParameters(commonPrm)
body := req.GetBody()
p.WithAddress(objectSDK.NewAddressFromV2(body.GetAddress()))
@ -165,9 +163,7 @@ func (s *Service) toRangePrm(req *objectV2.GetRangeRequest, stream objectSvc.Get
}
p := new(getsvc.RangePrm)
p.SetCommonParameters(commonPrm.
WithKeyStorage(s.keyStorage),
)
p.SetCommonParameters(commonPrm)
body := req.GetBody()
p.WithAddress(objectSDK.NewAddressFromV2(body.GetAddress()))
@ -266,9 +262,7 @@ func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.Ran
}
p := new(getsvc.RangeHashPrm)
p.SetCommonParameters(commonPrm.
WithKeyStorage(s.keyStorage),
)
p.SetCommonParameters(commonPrm)
body := req.GetBody()
p.WithAddress(objectSDK.NewAddressFromV2(body.GetAddress()))
@ -324,9 +318,7 @@ func (s *Service) toHeadPrm(ctx context.Context, req *objectV2.HeadRequest, resp
}
p := new(getsvc.HeadPrm)
p.SetCommonParameters(commonPrm.
WithKeyStorage(s.keyStorage),
)
p.SetCommonParameters(commonPrm)
body := req.GetBody()
p.WithAddress(objectSDK.NewAddressFromV2(body.GetAddress()))