diff --git a/pkg/morph/client/container/client.go b/pkg/morph/client/container/client.go index c3aa46baee..e7feca62e2 100644 --- a/pkg/morph/client/container/client.go +++ b/pkg/morph/client/container/client.go @@ -39,6 +39,9 @@ const ( // putNamedMethod is method name for container put with an alias. It is exported to provide custom fee. putNamedMethod = "putNamed" + + addNextEpochNodes = "addNextEpochNodes" + commitContainerListUpdate = "commitContainerListUpdate" ) var ( diff --git a/pkg/morph/client/container/nodes.go b/pkg/morph/client/container/nodes.go new file mode 100644 index 0000000000..f01c7d407e --- /dev/null +++ b/pkg/morph/client/container/nodes.go @@ -0,0 +1,50 @@ +package container + +import ( + "fmt" + + "github.com/nspcc-dev/neofs-node/pkg/morph/client" +) + +// AddNextEpochNodes registers public keys as a container's placement vector +// with specified index. Registration must be finished with final +// [Client.CommitContainerListUpdate] call. Always sends a notary request with +// Alphabet multi-signature. +func (c *Client) AddNextEpochNodes(cid []byte, placementIndex int, nodesKeys [][]byte) error { + if len(cid) == 0 || len(nodesKeys) == 0 { + return errNilArgument + } + + prm := client.InvokePrm{} + prm.SetMethod(addNextEpochNodes) + prm.SetArgs(cid, placementIndex, nodesKeys) + prm.RequireAlphabetSignature() + + err := c.client.Invoke(prm) + if err != nil { + return fmt.Errorf("could not invoke method (%s): %w", addNextEpochNodes, err) + } + + return nil +} + +// CommitContainerListUpdate finishes container placement updates for the current +// epoch made by former [Client.AddNextEpochNodes] calls. Always sends a notary +// request with Alphabet multi-signature. +func (c *Client) CommitContainerListUpdate(cid []byte, replicas []uint32) error { + if len(cid) == 0 || len(replicas) == 0 { + return errNilArgument + } + + prm := client.InvokePrm{} + prm.SetMethod(commitContainerListUpdate) + prm.SetArgs(cid, replicas) + prm.RequireAlphabetSignature() + + err := c.client.Invoke(prm) + if err != nil { + return fmt.Errorf("could not invoke method (%s): %w", commitContainerListUpdate, err) + } + + return nil +}