From 43e367f52c4765537fff976a7dbef18c6dba3322 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 23 Mar 2021 13:30:49 +0300 Subject: [PATCH] [#446] morph/client: Remove inner ring list method Inner ring list should be accessed from side chain `RoleManagement` contract by NeoFSAlphabet role. Signed-off-by: Alex Vanin --- pkg/morph/client/netmap/client.go | 32 +++--------- pkg/morph/client/netmap/ir_list.go | 61 ----------------------- pkg/morph/client/netmap/wrapper/irlist.go | 21 -------- 3 files changed, 7 insertions(+), 107 deletions(-) delete mode 100644 pkg/morph/client/netmap/ir_list.go delete mode 100644 pkg/morph/client/netmap/wrapper/irlist.go diff --git a/pkg/morph/client/netmap/client.go b/pkg/morph/client/netmap/client.go index 0c54f4bb..9afd706c 100644 --- a/pkg/morph/client/netmap/client.go +++ b/pkg/morph/client/netmap/client.go @@ -37,20 +37,18 @@ type cfg struct { snapshotMethod, // get network map snapshot method name epochSnapshotMethod, // get network map snapshot by epoch method name updateStateMethod, // update state method name for invocation - innerRingListMethod, // IR list method name for invocation epochMethod, // get epoch number method name configMethod string // get config value method name } const ( - defaultAddPeerMethod = "addPeer" // default add peer method name - defaultNewEpochMethod = "newEpoch" // default new epoch method name - defaultNetMapMethod = "netmap" // default get network map method name - defaultSnapshotMethod = "snapshot" // default get network map snapshot method name - defaultUpdateStateMethod = "updateState" // default update state method name - defaultInnerRIngListMethod = "innerRingList" // default IR list method name - defaultEpochMethod = "epoch" // default get epoch number method name - defaultConfigMethod = "config" // default get config value method name + defaultAddPeerMethod = "addPeer" // default add peer method name + defaultNewEpochMethod = "newEpoch" // default new epoch method name + defaultNetMapMethod = "netmap" // default get network map method name + defaultSnapshotMethod = "snapshot" // default get network map snapshot method name + defaultUpdateStateMethod = "updateState" // default update state method name + defaultEpochMethod = "epoch" // default get epoch number method name + defaultConfigMethod = "config" // default get config value method name defaultEpochSnapshotMethod = "snapshotByEpoch" // default get network map snapshot by epoch method name ) @@ -63,7 +61,6 @@ func defaultConfig() *cfg { snapshotMethod: defaultSnapshotMethod, epochSnapshotMethod: defaultEpochSnapshotMethod, updateStateMethod: defaultUpdateStateMethod, - innerRingListMethod: defaultInnerRIngListMethod, epochMethod: defaultEpochMethod, configMethod: defaultConfigMethod, } @@ -78,7 +75,6 @@ func defaultConfig() *cfg { // * new epoch method name: NewEpoch; // * get network map method name: Netmap; // * update state method name: UpdateState; -// * inner ring list method name: InnerRingList. // // If desired option satisfies the default value, it can be omitted. // If multiple options of the same config value are supplied, @@ -157,20 +153,6 @@ func WithUpdateStateMethod(n string) Option { } } -// WithInnerRingListMethod returns a client constructor option that -// specifies the method name of inner ring listing operation. -// -// Ignores empty value. -// -// If option not provided, "InnerRingList" is used. -func WithInnerRingListMethod(n string) Option { - return func(c *cfg) { - if n != "" { - c.innerRingListMethod = n - } - } -} - // WithEpochMethod returns a client constructor option that // specifies the method name of epoch number receiving operation. // diff --git a/pkg/morph/client/netmap/ir_list.go b/pkg/morph/client/netmap/ir_list.go deleted file mode 100644 index 2587fc12..00000000 --- a/pkg/morph/client/netmap/ir_list.go +++ /dev/null @@ -1,61 +0,0 @@ -package netmap - -import ( - "github.com/nspcc-dev/neofs-node/pkg/morph/client" - "github.com/pkg/errors" -) - -// InnerRingListArgs groups the arguments -// of inner ring list test invoke call. -type InnerRingListArgs struct { -} - -// InnerRingListValues groups the stack parameters -// returned by inner ring list test invoke. -type InnerRingListValues struct { - keys [][]byte // list of keys of IR nodes in a binary format -} - -// KeyList return the list of IR node keys -// in a binary format. -func (g InnerRingListValues) KeyList() [][]byte { - return g.keys -} - -// InnerRingList performs the test invoke of inner ring list -// method of NeoFS Netmap contract. -func (c *Client) InnerRingList(args InnerRingListArgs) (*InnerRingListValues, error) { - prms, err := c.client.TestInvoke( - c.innerRingListMethod, - ) - if err != nil { - return nil, errors.Wrapf(err, "could not perform test invocation (%s)", c.innerRingListMethod) - } else if ln := len(prms); ln != 1 { - return nil, errors.Errorf("unexpected stack item count (%s): %d", c.innerRingListMethod, ln) - } - - prms, err = client.ArrayFromStackItem(prms[0]) - if err != nil { - return nil, errors.Wrapf(err, "could not get stack item array from stack item (%s)", c.innerRingListMethod) - } - - res := &InnerRingListValues{ - keys: make([][]byte, 0, len(prms)), - } - - for i := range prms { - nodePrms, err := client.ArrayFromStackItem(prms[i]) - if err != nil { - return nil, errors.Wrap(err, "could not get stack item array (Node #%d)") - } - - key, err := client.BytesFromStackItem(nodePrms[0]) - if err != nil { - return nil, errors.Wrapf(err, "could not parse stack item (Key #%d)", i) - } - - res.keys = append(res.keys, key) - } - - return res, nil -} diff --git a/pkg/morph/client/netmap/wrapper/irlist.go b/pkg/morph/client/netmap/wrapper/irlist.go deleted file mode 100644 index e339d40e..00000000 --- a/pkg/morph/client/netmap/wrapper/irlist.go +++ /dev/null @@ -1,21 +0,0 @@ -package wrapper - -import ( - contract "github.com/nspcc-dev/neofs-node/pkg/morph/client/netmap" - "github.com/pkg/errors" -) - -// InnerRingKeys receives public key list of inner -// ring nodes through Netmap contract call and returns it. -func (w *Wrapper) InnerRingKeys() ([][]byte, error) { - // prepare invocation arguments - args := contract.InnerRingListArgs{} - - // invoke smart contract call - values, err := w.client.InnerRingList(args) - if err != nil { - return nil, errors.Wrap(err, "could not invoke smart contract") - } - - return values.KeyList(), nil -}