[#1400] owner: Upgrade SDK package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f8ac4632f8
commit
bb25ecbd15
60 changed files with 379 additions and 327 deletions
|
@ -2,13 +2,13 @@ package persistent
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/owner"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
|
@ -18,9 +18,16 @@ import (
|
|||
// Returns response that is filled with just created token's
|
||||
// ID and public key for it.
|
||||
func (s *TokenStore) Create(ctx context.Context, body *session.CreateRequestBody) (*session.CreateResponseBody, error) {
|
||||
ownerBytes, err := owner.NewIDFromV2(body.GetOwnerID()).Marshal()
|
||||
idV2 := body.GetOwnerID()
|
||||
if idV2 == nil {
|
||||
return nil, errors.New("missing owner")
|
||||
}
|
||||
|
||||
var id user.ID
|
||||
|
||||
err := id.ReadFromV2(*idV2)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, fmt.Errorf("invalid owner: %w", err)
|
||||
}
|
||||
|
||||
uidBytes, err := storage.NewTokenID()
|
||||
|
@ -41,21 +48,15 @@ func (s *TokenStore) Create(ctx context.Context, body *session.CreateRequestBody
|
|||
err = s.db.Update(func(tx *bbolt.Tx) error {
|
||||
rootBucket := tx.Bucket(sessionsBucket)
|
||||
|
||||
ownerBucket, err := rootBucket.CreateBucketIfNotExists(ownerBytes)
|
||||
ownerBucket, err := rootBucket.CreateBucketIfNotExists(id.WalletBytes())
|
||||
if err != nil {
|
||||
return fmt.Errorf(
|
||||
"could not get/create %s owner bucket: %w",
|
||||
hex.EncodeToString(ownerBytes),
|
||||
err,
|
||||
)
|
||||
"could not get/create %s owner bucket: %w", id, err)
|
||||
}
|
||||
|
||||
err = ownerBucket.Put(uidBytes, value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not put session token for %s oid: %w",
|
||||
hex.EncodeToString(ownerBytes),
|
||||
err,
|
||||
)
|
||||
return fmt.Errorf("could not put session token for %s oid: %w", id, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue