Merge pull request #3394 from nspcc-dev/better-notary-actor

rpcclient: make default Notary actor options customizable
This commit is contained in:
Anna Shaleva 2024-04-03 11:02:24 +03:00 committed by GitHub
commit c81ed22698
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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}}