forked from TrueCloudLab/frostfs-node
79 lines
1.7 KiB
Go
79 lines
1.7 KiB
Go
package frostfscontract
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
)
|
|
|
|
// ChequePrm groups parameters of Cheque operation.
|
|
type ChequePrm struct {
|
|
id []byte
|
|
user util.Uint160
|
|
amount int64
|
|
lock util.Uint160
|
|
|
|
client.InvokePrmOptional
|
|
}
|
|
|
|
// SetID sets ID of the cheque.
|
|
func (c *ChequePrm) SetID(id []byte) {
|
|
c.id = id
|
|
}
|
|
|
|
// SetUser sets user.
|
|
func (c *ChequePrm) SetUser(user util.Uint160) {
|
|
c.user = user
|
|
}
|
|
|
|
// SetAmount sets amount.
|
|
func (c *ChequePrm) SetAmount(amount int64) {
|
|
c.amount = amount
|
|
}
|
|
|
|
// SetLock sets lock.
|
|
func (c *ChequePrm) SetLock(lock util.Uint160) {
|
|
c.lock = lock
|
|
}
|
|
|
|
// Cheque invokes `cheque` method of FrostFS contract.
|
|
func (x *Client) Cheque(ctx context.Context, p ChequePrm) error {
|
|
prm := client.InvokePrm{}
|
|
prm.SetMethod(chequeMethod)
|
|
prm.SetArgs(p.id, p.user, p.amount, p.lock)
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
|
|
|
_, err := x.client.Invoke(ctx, prm)
|
|
return err
|
|
}
|
|
|
|
// AlphabetUpdatePrm groups parameters of AlphabetUpdate operation.
|
|
type AlphabetUpdatePrm struct {
|
|
id []byte
|
|
pubs keys.PublicKeys
|
|
|
|
client.InvokePrmOptional
|
|
}
|
|
|
|
// SetID sets update ID.
|
|
func (a *AlphabetUpdatePrm) SetID(id []byte) {
|
|
a.id = id
|
|
}
|
|
|
|
// SetPubs sets new alphabet public keys.
|
|
func (a *AlphabetUpdatePrm) SetPubs(pubs keys.PublicKeys) {
|
|
a.pubs = pubs
|
|
}
|
|
|
|
// AlphabetUpdate update list of alphabet nodes.
|
|
func (x *Client) AlphabetUpdate(ctx context.Context, p AlphabetUpdatePrm) error {
|
|
prm := client.InvokePrm{}
|
|
prm.SetMethod(alphabetUpdateMethod)
|
|
prm.SetArgs(p.id, p.pubs)
|
|
prm.InvokePrmOptional = p.InvokePrmOptional
|
|
|
|
_, err := x.client.Invoke(ctx, prm)
|
|
return err
|
|
}
|