forked from TrueCloudLab/frostfs-node
[#1369] version: Upgrade SDK package
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7a57d7b076
commit
088df0e2a9
13 changed files with 58 additions and 36 deletions
|
@ -171,8 +171,10 @@ It will be stored in sidechain when inner ring will accepts it.`,
|
|||
idOwner = owner.NewIDFromPublicKey(&key.PublicKey)
|
||||
}
|
||||
|
||||
ver := versionSDK.Current()
|
||||
|
||||
cnr := container.New()
|
||||
cnr.SetVersion(versionSDK.Current())
|
||||
cnr.SetVersion(&ver)
|
||||
cnr.SetPlacementPolicy(placementPolicy)
|
||||
cnr.SetBasicACL(basicACL)
|
||||
cnr.SetAttributes(attributes)
|
||||
|
@ -807,9 +809,8 @@ func parseEACL(eaclPath string) (*eacl.Table, error) {
|
|||
}
|
||||
|
||||
func validateAndFixEACLVersion(table *eacl.Table) {
|
||||
v := table.Version()
|
||||
if !version.IsValid(v) {
|
||||
table.SetVersion(*versionSDK.Current())
|
||||
if !version.IsValid(table.Version()) {
|
||||
table.SetVersion(versionSDK.Current())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/util/keyer"
|
||||
locodedb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db"
|
||||
airportsdb "github.com/nspcc-dev/neofs-node/pkg/util/locode/db/airports"
|
||||
|
@ -427,7 +428,11 @@ func completeBearerToken(btok *token.BearerToken) error {
|
|||
if v2 := btok.ToV2(); v2 != nil {
|
||||
// set eACL table version, because it usually omitted
|
||||
table := v2.GetBody().GetEACL()
|
||||
table.SetVersion(version.Current().ToV2())
|
||||
|
||||
var ver refs.Version
|
||||
version.Current().WriteToV2(&ver)
|
||||
|
||||
table.SetVersion(&ver)
|
||||
} else {
|
||||
return errors.New("unsupported bearer token version")
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ type cfg struct {
|
|||
|
||||
ownerIDFromKey *owner.ID // owner ID calculated from key
|
||||
|
||||
apiVersion *version.Version
|
||||
apiVersion version.Version
|
||||
|
||||
cfgGRPC cfgGRPC
|
||||
|
||||
|
|
2
go.mod
2
go.mod
|
@ -19,7 +19,7 @@ require (
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220321144137-d5a9af5860af // indirect
|
||||
github.com/nspcc-dev/neofs-api-go/v2 v2.12.1
|
||||
github.com/nspcc-dev/neofs-contract v0.14.2
|
||||
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220412151250-3e75660802ae
|
||||
github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.3.0.20220413072812-c961aea14446
|
||||
github.com/nspcc-dev/tzhash v1.5.2
|
||||
github.com/panjf2000/ants/v2 v2.4.0
|
||||
github.com/paulmach/orb v0.2.2
|
||||
|
|
BIN
go.sum
BIN
go.sum
Binary file not shown.
|
@ -22,7 +22,8 @@ func TestCheckFormat(t *testing.T) {
|
|||
|
||||
require.Error(t, CheckFormat(c))
|
||||
|
||||
c.SetVersion(version.Current())
|
||||
ver := version.Current()
|
||||
c.SetVersion(&ver)
|
||||
|
||||
require.Error(t, CheckFormat(c))
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func TestIsValid(t *testing.T) {
|
||||
require.True(t, version.IsValid(*versionSDK.Current()))
|
||||
require.True(t, version.IsValid(versionSDK.Current()))
|
||||
|
||||
var v versionSDK.Version
|
||||
|
||||
|
|
|
@ -148,9 +148,9 @@ func testOID() *oidSDK.ID {
|
|||
}
|
||||
|
||||
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
||||
version := version.New()
|
||||
version.SetMajor(2)
|
||||
version.SetMinor(1)
|
||||
var ver version.Version
|
||||
ver.SetMajor(2)
|
||||
ver.SetMinor(1)
|
||||
|
||||
csum := new(checksum.Checksum)
|
||||
csum.SetSHA256(sha256.Sum256(owner.PublicKeyToIDBytes(&test.DecodeKey(-1).PublicKey)))
|
||||
|
@ -162,7 +162,7 @@ func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
|||
obj.SetID(testOID())
|
||||
obj.SetOwnerID(ownertest.ID())
|
||||
obj.SetContainerID(cid)
|
||||
obj.SetVersion(version)
|
||||
obj.SetVersion(&ver)
|
||||
obj.SetPayloadChecksum(csum)
|
||||
obj.SetPayloadHomomorphicHash(csumTZ)
|
||||
obj.SetPayload([]byte{1, 2, 3, 4, 5})
|
||||
|
|
|
@ -68,9 +68,9 @@ func generateObject(t testing.TB) *object.Object {
|
|||
}
|
||||
|
||||
func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
||||
version := version.New()
|
||||
version.SetMajor(2)
|
||||
version.SetMinor(1)
|
||||
var ver version.Version
|
||||
ver.SetMajor(2)
|
||||
ver.SetMinor(1)
|
||||
|
||||
csum := new(checksum.Checksum)
|
||||
csum.SetSHA256(sha256.Sum256(owner.PublicKeyToIDBytes(&test.DecodeKey(-1).PublicKey)))
|
||||
|
@ -82,7 +82,7 @@ func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
|||
obj.SetID(testOID())
|
||||
obj.SetOwnerID(ownertest.ID())
|
||||
obj.SetContainerID(cid)
|
||||
obj.SetVersion(version)
|
||||
obj.SetVersion(&ver)
|
||||
obj.SetPayloadChecksum(csum)
|
||||
obj.SetPayloadHomomorphicHash(csumTZ)
|
||||
obj.SetPayload([]byte{1, 2, 3, 4, 5})
|
||||
|
|
|
@ -82,9 +82,9 @@ func generateObjectWithCID(t *testing.T, cid *cid.ID) *object.Object {
|
|||
}
|
||||
|
||||
func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
|
||||
version := version.New()
|
||||
version.SetMajor(2)
|
||||
version.SetMinor(1)
|
||||
var ver version.Version
|
||||
ver.SetMajor(2)
|
||||
ver.SetMinor(1)
|
||||
|
||||
csum := new(checksum.Checksum)
|
||||
csum.SetSHA256(sha256.Sum256(data))
|
||||
|
@ -96,7 +96,7 @@ func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
|
|||
obj.SetID(generateOID())
|
||||
obj.SetOwnerID(ownertest.ID())
|
||||
obj.SetContainerID(cid)
|
||||
obj.SetVersion(version)
|
||||
obj.SetVersion(&ver)
|
||||
obj.SetPayload(data)
|
||||
obj.SetPayloadChecksum(csum)
|
||||
obj.SetPayloadHomomorphicHash(csumTZ)
|
||||
|
|
|
@ -2,14 +2,17 @@ package netmap
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/netmap"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/version"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/version"
|
||||
versionsdk "github.com/nspcc-dev/neofs-sdk-go/version"
|
||||
)
|
||||
|
||||
type executorSvc struct {
|
||||
version *version.Version
|
||||
version refs.Version
|
||||
|
||||
state NodeState
|
||||
|
||||
netInfo NetworkInfo
|
||||
|
@ -32,23 +35,32 @@ type NetworkInfo interface {
|
|||
Dump(*refs.Version) (*netmap.NetworkInfo, error)
|
||||
}
|
||||
|
||||
func NewExecutionService(s NodeState, v *version.Version, netInfo NetworkInfo) Server {
|
||||
if s == nil || v == nil || netInfo == nil {
|
||||
func NewExecutionService(s NodeState, v versionsdk.Version, netInfo NetworkInfo) Server {
|
||||
if s == nil || netInfo == nil || !version.IsValid(v) {
|
||||
// this should never happen, otherwise it programmers bug
|
||||
panic("can't create netmap execution service")
|
||||
}
|
||||
|
||||
return &executorSvc{
|
||||
version: v,
|
||||
res := &executorSvc{
|
||||
state: s,
|
||||
netInfo: netInfo,
|
||||
}
|
||||
|
||||
v.WriteToV2(&res.version)
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func (s *executorSvc) LocalNodeInfo(
|
||||
_ context.Context,
|
||||
req *netmap.LocalNodeInfoRequest) (*netmap.LocalNodeInfoResponse, error) {
|
||||
ver := version.NewFromV2(req.GetMetaHeader().GetVersion())
|
||||
verV2 := req.GetMetaHeader().GetVersion()
|
||||
if verV2 == nil {
|
||||
return nil, errors.New("missing version")
|
||||
}
|
||||
|
||||
var ver versionsdk.Version
|
||||
ver.ReadFromV2(*verV2)
|
||||
|
||||
ni, err := s.state.LocalNodeInfo()
|
||||
if err != nil {
|
||||
|
@ -69,7 +81,7 @@ func (s *executorSvc) LocalNodeInfo(
|
|||
}
|
||||
|
||||
body := new(netmap.LocalNodeInfoResponseBody)
|
||||
body.SetVersion(s.version.ToV2())
|
||||
body.SetVersion(&s.version)
|
||||
body.SetNodeInfo(ni)
|
||||
|
||||
resp := new(netmap.LocalNodeInfoResponse)
|
||||
|
|
|
@ -63,8 +63,9 @@ func (f *formatter) Write(p []byte) (n int, err error) {
|
|||
|
||||
func (f *formatter) Close() (*AccessIdentifiers, error) {
|
||||
curEpoch := f.prm.NetworkState.CurrentEpoch()
|
||||
ver := version.Current()
|
||||
|
||||
f.obj.SetVersion(version.Current())
|
||||
f.obj.SetVersion(&ver)
|
||||
f.obj.SetPayloadSize(f.sz)
|
||||
f.obj.SetSessionToken(f.prm.SessionToken)
|
||||
f.obj.SetCreationEpoch(curEpoch)
|
||||
|
|
|
@ -18,15 +18,17 @@ type Service struct {
|
|||
type Option func(*cfg)
|
||||
|
||||
type cfg struct {
|
||||
version *refs.Version
|
||||
version refs.Version
|
||||
|
||||
state netmap.State
|
||||
}
|
||||
|
||||
func defaultCfg() *cfg {
|
||||
return &cfg{
|
||||
version: version.Current().ToV2(),
|
||||
}
|
||||
var c cfg
|
||||
|
||||
version.Current().WriteToV2(&c.version)
|
||||
|
||||
return &c
|
||||
}
|
||||
|
||||
// NewService creates, initializes and returns Service instance.
|
||||
|
@ -44,7 +46,7 @@ func NewService(opts ...Option) *Service {
|
|||
|
||||
func setMeta(resp util.ResponseMessage, cfg *cfg) {
|
||||
meta := new(session.ResponseMetaHeader)
|
||||
meta.SetVersion(cfg.version)
|
||||
meta.SetVersion(&cfg.version)
|
||||
meta.SetTTL(1) // FIXME: #1160 TTL must be calculated
|
||||
meta.SetEpoch(cfg.state.CurrentEpoch())
|
||||
|
||||
|
|
Loading…
Reference in a new issue