forked from TrueCloudLab/frostfs-node
[#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 <alexey@nspcc.ru>
This commit is contained in:
parent
861307b192
commit
43e367f52c
3 changed files with 7 additions and 107 deletions
|
@ -37,20 +37,18 @@ type cfg struct {
|
||||||
snapshotMethod, // get network map snapshot method name
|
snapshotMethod, // get network map snapshot method name
|
||||||
epochSnapshotMethod, // get network map snapshot by epoch method name
|
epochSnapshotMethod, // get network map snapshot by epoch method name
|
||||||
updateStateMethod, // update state method name for invocation
|
updateStateMethod, // update state method name for invocation
|
||||||
innerRingListMethod, // IR list method name for invocation
|
|
||||||
epochMethod, // get epoch number method name
|
epochMethod, // get epoch number method name
|
||||||
configMethod string // get config value method name
|
configMethod string // get config value method name
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultAddPeerMethod = "addPeer" // default add peer method name
|
defaultAddPeerMethod = "addPeer" // default add peer method name
|
||||||
defaultNewEpochMethod = "newEpoch" // default new epoch method name
|
defaultNewEpochMethod = "newEpoch" // default new epoch method name
|
||||||
defaultNetMapMethod = "netmap" // default get network map method name
|
defaultNetMapMethod = "netmap" // default get network map method name
|
||||||
defaultSnapshotMethod = "snapshot" // default get network map snapshot method name
|
defaultSnapshotMethod = "snapshot" // default get network map snapshot method name
|
||||||
defaultUpdateStateMethod = "updateState" // default update state method name
|
defaultUpdateStateMethod = "updateState" // default update state method name
|
||||||
defaultInnerRIngListMethod = "innerRingList" // default IR list method name
|
defaultEpochMethod = "epoch" // default get epoch number method name
|
||||||
defaultEpochMethod = "epoch" // default get epoch number method name
|
defaultConfigMethod = "config" // default get config value method name
|
||||||
defaultConfigMethod = "config" // default get config value method name
|
|
||||||
|
|
||||||
defaultEpochSnapshotMethod = "snapshotByEpoch" // default get network map snapshot by epoch method name
|
defaultEpochSnapshotMethod = "snapshotByEpoch" // default get network map snapshot by epoch method name
|
||||||
)
|
)
|
||||||
|
@ -63,7 +61,6 @@ func defaultConfig() *cfg {
|
||||||
snapshotMethod: defaultSnapshotMethod,
|
snapshotMethod: defaultSnapshotMethod,
|
||||||
epochSnapshotMethod: defaultEpochSnapshotMethod,
|
epochSnapshotMethod: defaultEpochSnapshotMethod,
|
||||||
updateStateMethod: defaultUpdateStateMethod,
|
updateStateMethod: defaultUpdateStateMethod,
|
||||||
innerRingListMethod: defaultInnerRIngListMethod,
|
|
||||||
epochMethod: defaultEpochMethod,
|
epochMethod: defaultEpochMethod,
|
||||||
configMethod: defaultConfigMethod,
|
configMethod: defaultConfigMethod,
|
||||||
}
|
}
|
||||||
|
@ -78,7 +75,6 @@ func defaultConfig() *cfg {
|
||||||
// * new epoch method name: NewEpoch;
|
// * new epoch method name: NewEpoch;
|
||||||
// * get network map method name: Netmap;
|
// * get network map method name: Netmap;
|
||||||
// * update state method name: UpdateState;
|
// * update state method name: UpdateState;
|
||||||
// * inner ring list method name: InnerRingList.
|
|
||||||
//
|
//
|
||||||
// If desired option satisfies the default value, it can be omitted.
|
// If desired option satisfies the default value, it can be omitted.
|
||||||
// If multiple options of the same config value are supplied,
|
// 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
|
// WithEpochMethod returns a client constructor option that
|
||||||
// specifies the method name of epoch number receiving operation.
|
// specifies the method name of epoch number receiving operation.
|
||||||
//
|
//
|
||||||
|
|
|
@ -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
|
|
||||||
}
|
|
|
@ -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
|
|
||||||
}
|
|
Loading…
Reference in a new issue