rpcclient: make default Notary actor options customizable

This commit allows to override only MainModifier omitting overriding
MainCheckerModifier.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2024-04-02 18:56:43 +03:00
parent 309016561d
commit 182762af5a
2 changed files with 6 additions and 6 deletions

View file

@ -88,8 +88,8 @@ type RPCActor interface {
// NewDefaultActorOptions returns the default Actor options. Internal functions // NewDefaultActorOptions returns the default Actor options. Internal functions
// of it need some data from the contract, so it should be added. // of it need some data from the contract, so it should be added.
func NewDefaultActorOptions(reader *ContractReader, acc *wallet.Account) ActorOptions { func NewDefaultActorOptions(reader *ContractReader, acc *wallet.Account) *ActorOptions {
opts := ActorOptions{ opts := &ActorOptions{
FbScript: []byte{byte(opcode.RET)}, FbScript: []byte{byte(opcode.RET)},
FbSigner: actor.SignerAccount{ FbSigner: actor.SignerAccount{
Signer: transaction.Signer{ Signer: transaction.Signer{
@ -132,8 +132,8 @@ func NewActor(c RPCActor, signers []actor.SignerAccount, simpleAcc *wallet.Accou
// NewTunedActor is the same as NewActor, but allows to override the default // NewTunedActor is the same as NewActor, but allows to override the default
// options (see ActorOptions for details). Use with care. // options (see ActorOptions for details). Use with care.
func NewTunedActor(c RPCActor, signers []actor.SignerAccount, opts ActorOptions) (*Actor, error) { func NewTunedActor(c RPCActor, signers []actor.SignerAccount, opts *ActorOptions) (*Actor, error) {
return newTunedActor(c, signers, opts.FbSigner.Account, &opts) return newTunedActor(c, signers, opts.FbSigner.Account, opts)
} }
func newTunedActor(c RPCActor, signers []actor.SignerAccount, simpleAcc *wallet.Account, opts *ActorOptions) (*Actor, error) { func newTunedActor(c RPCActor, signers []actor.SignerAccount, simpleAcc *wallet.Account, opts *ActorOptions) (*Actor, error) {
@ -174,7 +174,7 @@ func newTunedActor(c RPCActor, signers []actor.SignerAccount, simpleAcc *wallet.
reader := NewReader(invoker.New(c, nil)) reader := NewReader(invoker.New(c, nil))
if opts == nil { if opts == nil {
defOpts := NewDefaultActorOptions(reader, simpleAcc) defOpts := NewDefaultActorOptions(reader, simpleAcc)
opts = &defOpts opts = defOpts
} }
var notarySA = actor.SignerAccount{ var notarySA = actor.SignerAccount{
Signer: transaction.Signer{ Signer: transaction.Signer{

View file

@ -54,7 +54,7 @@ func ExampleActor() {
panic("deposit failed") panic("deposit failed")
} }
var opts notary.ActorOptions var opts = new(notary.ActorOptions)
// Add high priority attribute, we gonna be making committee-signed transactions anyway. // Add high priority attribute, we gonna be making committee-signed transactions anyway.
opts.MainAttributes = []transaction.Attribute{{Type: transaction.HighPriority}} opts.MainAttributes = []transaction.Attribute{{Type: transaction.HighPriority}}