From 97fe50d4525b37deb54bd5a36780d34307d998a3 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 23 Mar 2021 13:32:18 +0300 Subject: [PATCH] [#446] cmd/neofs-node: Get inner ring list from `RoleManagement` contract Signed-off-by: Alex Vanin --- cmd/neofs-node/object.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index 35b9e4e22c..b49f116899 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -15,6 +15,7 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/core/netmap" objectCore "github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" + morphClient "github.com/nspcc-dev/neofs-node/pkg/morph/client" "github.com/nspcc-dev/neofs-node/pkg/morph/client/container/wrapper" "github.com/nspcc-dev/neofs-node/pkg/morph/event" "github.com/nspcc-dev/neofs-node/pkg/network" @@ -138,6 +139,24 @@ func (i *delNetInfo) TombstoneLifetime() (uint64, error) { return i.tsLifetime, nil } +type innerRingFetcher struct { + sidechain *morphClient.Client +} + +func (n *innerRingFetcher) InnerRingKeys() ([][]byte, error) { + keys, err := n.sidechain.NeoFSAlphabetList() + if err != nil { + return nil, errors.Wrap(err, "can't get inner ring keys") + } + + result := make([][]byte, 0, len(keys)) + for i := range keys { + result = append(result, keys[i].Bytes()) + } + + return result, nil +} + func initObjectService(c *cfg) { ls := c.cfgObject.cfgLocalStorage.localStorage keyStorage := util.NewKeyStorage(c.key, c.privateTokenStore) @@ -159,6 +178,10 @@ func initObjectService(c *cfg) { basicConstructor: clientCache, } + irFetcher := &innerRingFetcher{ + sidechain: c.cfgMorph.client, + } + objRemover := &localObjectRemover{ storage: ls, log: c.log, @@ -338,7 +361,7 @@ func initObjectService(c *cfg) { acl.WithSenderClassifier( acl.NewSenderClassifier( c.log, - c.cfgNetmap.wrapper, + irFetcher, c.cfgNetmap.wrapper, ), ),