[#1255] object: Add persistent storage usage

Use persistent storage usage in the node if it was configured so.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-03-21 17:56:56 +03:00 committed by Alex Vanin
parent 9cda3121ab
commit 90a8c52bdb
4 changed files with 57 additions and 6 deletions

View file

@ -4,22 +4,35 @@ import (
"crypto/ecdsa"
"github.com/nspcc-dev/neofs-node/pkg/core/netmap"
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage/temporary"
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
apistatus "github.com/nspcc-dev/neofs-sdk-go/client/status"
"github.com/nspcc-dev/neofs-sdk-go/owner"
"github.com/nspcc-dev/neofs-sdk-go/session"
)
// SessionSource is an interface tha provides
// access to node's actual (not expired) session
// tokens.
type SessionSource interface {
// Get must return non-expired private token that
// corresponds with passed owner and tokenID. If
// token has not been created, has been expired
// of it is impossible to get information about the
// token Get must return nil.
Get(owner *owner.ID, tokenID []byte) *storage.PrivateToken
}
// KeyStorage represents private key storage of the local node.
type KeyStorage struct {
key *ecdsa.PrivateKey
tokenStore *temporary.TokenStore
tokenStore SessionSource
networkState netmap.State
}
// NewKeyStorage creates, initializes and returns new KeyStorage instance.
func NewKeyStorage(localKey *ecdsa.PrivateKey, tokenStore *temporary.TokenStore, net netmap.State) *KeyStorage {
func NewKeyStorage(localKey *ecdsa.PrivateKey, tokenStore SessionSource, net netmap.State) *KeyStorage {
return &KeyStorage{
key: localKey,
tokenStore: tokenStore,