2020-07-24 16:54:03 +03:00
|
|
|
package netmap
|
|
|
|
|
2021-05-18 11:12:51 +03:00
|
|
|
import (
|
|
|
|
"fmt"
|
2021-11-09 23:52:29 +03:00
|
|
|
|
2023-03-07 16:38:26 +03:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
2021-05-18 11:12:51 +03:00
|
|
|
)
|
2020-07-24 16:54:03 +03:00
|
|
|
|
2023-02-05 18:59:38 +03:00
|
|
|
// NewEpoch updates FrostFS epoch number through
|
2022-01-31 14:58:55 +03:00
|
|
|
// Netmap contract call.
|
2023-11-13 17:22:31 +03:00
|
|
|
func (c *Client) NewEpoch(epoch uint64) error {
|
|
|
|
prm := client.InvokePrm{}
|
|
|
|
prm.SetMethod(newEpochMethod)
|
|
|
|
prm.SetArgs(epoch)
|
|
|
|
|
|
|
|
_, err := c.client.Invoke(prm)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("could not invoke method (%s): %w", newEpochMethod, err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewEpochControl updates FrostFS epoch number through
|
|
|
|
// control notary transaction internally to ensure all
|
|
|
|
// nodes produce the same transaction with high probability.
|
2023-11-08 12:05:03 +03:00
|
|
|
// If vub > 0, vub will be used as valid until block value.
|
2023-11-13 17:22:31 +03:00
|
|
|
func (c *Client) NewEpochControl(epoch uint64, vub uint32) (uint32, error) {
|
2021-11-09 23:52:29 +03:00
|
|
|
prm := client.InvokePrm{}
|
2022-01-29 16:06:36 +03:00
|
|
|
prm.SetMethod(newEpochMethod)
|
2022-03-11 12:28:34 +03:00
|
|
|
prm.SetArgs(epoch)
|
2023-11-13 17:22:31 +03:00
|
|
|
prm.SetControlTX(true)
|
2023-11-08 12:05:03 +03:00
|
|
|
prm.SetVUB(vub)
|
2021-11-09 23:52:29 +03:00
|
|
|
|
2023-11-08 12:05:03 +03:00
|
|
|
res, err := c.client.Invoke(prm)
|
|
|
|
if err != nil {
|
|
|
|
return 0, fmt.Errorf("could not invoke method (%s): %w", newEpochMethod, err)
|
2021-05-18 11:12:51 +03:00
|
|
|
}
|
2023-11-08 12:05:03 +03:00
|
|
|
return res.VUB, nil
|
2020-07-24 16:54:03 +03:00
|
|
|
}
|