2020-07-24 13:54:03 +00:00
|
|
|
package invoke
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-08-27 12:37:01 +00:00
|
|
|
getEpochMethod = "epoch"
|
|
|
|
setNewEpochMethod = "newEpoch"
|
2020-07-24 13:54:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Epoch return epoch value from contract.
|
|
|
|
func Epoch(cli *client.Client, con util.Uint160) (int64, error) {
|
|
|
|
if cli == nil {
|
|
|
|
return 0, client.ErrNilClient
|
|
|
|
}
|
|
|
|
|
|
|
|
val, err := cli.TestInvoke(con, getEpochMethod)
|
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
2020-08-27 11:57:52 +00:00
|
|
|
epoch, err := client.IntFromStackItem(val[0])
|
2020-07-24 13:54:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return epoch, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNewEpoch invokes NewEpoch method.
|
|
|
|
func SetNewEpoch(cli *client.Client, con util.Uint160, epoch uint64) error {
|
|
|
|
if cli == nil {
|
|
|
|
return client.ErrNilClient
|
|
|
|
}
|
|
|
|
|
|
|
|
return cli.Invoke(con, extraFee, setNewEpochMethod, int64(epoch))
|
|
|
|
}
|