forked from TrueCloudLab/frostfs-node
[#787] morph: Return VUB for IR service calls
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
518f3baf41
commit
2393d13e4d
12 changed files with 78 additions and 41 deletions
|
@ -11,14 +11,17 @@ import (
|
|||
// If `force` is true, this call is normally initiated by a control
|
||||
// service command and uses a control notary transaction internally
|
||||
// to ensure all nodes produce the same transaction with high probability.
|
||||
func (c *Client) NewEpoch(epoch uint64, force bool) error {
|
||||
// If vub > 0, vub will be used as valid until block value.
|
||||
func (c *Client) NewEpoch(epoch uint64, vub uint32, force bool) (uint32, error) {
|
||||
prm := client.InvokePrm{}
|
||||
prm.SetMethod(newEpochMethod)
|
||||
prm.SetArgs(epoch)
|
||||
prm.SetControlTX(force)
|
||||
prm.SetVUB(vub)
|
||||
|
||||
if _, err := c.client.Invoke(prm); err != nil {
|
||||
return fmt.Errorf("could not invoke method (%s): %w", newEpochMethod, err)
|
||||
res, err := c.client.Invoke(prm)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("could not invoke method (%s): %w", newEpochMethod, err)
|
||||
}
|
||||
return nil
|
||||
return res.VUB, nil
|
||||
}
|
||||
|
|
|
@ -43,17 +43,20 @@ func (c *Client) AddPeer(p AddPeerPrm) error {
|
|||
}
|
||||
|
||||
// ForceRemovePeer marks the given peer as offline via a notary control transaction.
|
||||
func (c *Client) ForceRemovePeer(nodeInfo netmap.NodeInfo) error {
|
||||
// If vub > 0, vub will be used as valid until block value.
|
||||
func (c *Client) ForceRemovePeer(nodeInfo netmap.NodeInfo, vub uint32) (uint32, error) {
|
||||
if !c.client.WithNotary() {
|
||||
return fmt.Errorf("peer can be forcefully removed only in notary environment")
|
||||
return 0, fmt.Errorf("peer can be forcefully removed only in notary environment")
|
||||
}
|
||||
|
||||
prm := UpdatePeerPrm{}
|
||||
prm.SetKey(nodeInfo.PublicKey())
|
||||
prm.SetControlTX(true)
|
||||
prm.SetVUB(vub)
|
||||
|
||||
if err := c.UpdatePeerState(prm); err != nil {
|
||||
return fmt.Errorf("updating peer state: %v", err)
|
||||
vub, err := c.UpdatePeerState(prm)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("updating peer state: %v", err)
|
||||
}
|
||||
return nil
|
||||
return vub, nil
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func (u *UpdatePeerPrm) SetMaintenance() {
|
|||
}
|
||||
|
||||
// UpdatePeerState changes peer status through Netmap contract call.
|
||||
func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
|
||||
func (c *Client) UpdatePeerState(p UpdatePeerPrm) (uint32, error) {
|
||||
method := updateStateMethod
|
||||
|
||||
if c.client.WithNotary() && c.client.IsAlpha() {
|
||||
|
@ -55,8 +55,9 @@ func (c *Client) UpdatePeerState(p UpdatePeerPrm) error {
|
|||
prm.SetArgs(int64(p.state), p.key)
|
||||
prm.InvokePrmOptional = p.InvokePrmOptional
|
||||
|
||||
if _, err := c.client.Invoke(prm); err != nil {
|
||||
return fmt.Errorf("could not invoke smart contract: %w", err)
|
||||
res, err := c.client.Invoke(prm)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("could not invoke smart contract: %w", err)
|
||||
}
|
||||
return nil
|
||||
return res.VUB, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue