forked from TrueCloudLab/frostfs-node
Add Inner Ring code
This commit is contained in:
parent
dadfd90dcd
commit
b7b5079934
400 changed files with 11420 additions and 8690 deletions
61
pkg/morph/client/netmap/ir_list.go
Normal file
61
pkg/morph/client/netmap/ir_list.go
Normal file
|
@ -0,0 +1,61 @@
|
|||
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.ArrayFromStackParameter(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.ArrayFromStackParameter(prms[i])
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "could not get stack item array (Node #%d)")
|
||||
}
|
||||
|
||||
key, err := client.BytesFromStackParameter(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
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue