diff --git a/pkg/rpcclient/actor/actor.go b/pkg/rpcclient/actor/actor.go index bbaec24a8..b4b6a71e7 100644 --- a/pkg/rpcclient/actor/actor.go +++ b/pkg/rpcclient/actor/actor.go @@ -106,6 +106,10 @@ type Options struct { // before it's signed (other methods that perform test invocations // use CheckerModifier). MakeUnsigned* methods do not run it. Modifier TransactionModifier + // waiter.PollConfig is used by [waiter.Waiter] constructor to customize + // [waiter.PollingBased] behaviour. This option may be kept empty for default + // polling behaviour. + waiter.PollConfig } // New creates an Actor instance using the specified RPC interface and the set of @@ -183,6 +187,7 @@ func NewTuned(ra RPCActor, signers []SignerAccount, opts Options) (*Actor, error if opts.Modifier != nil { a.opts.Modifier = opts.Modifier } + a.Waiter = waiter.NewCustom(ra, a.version, opts.PollConfig) return a, err } diff --git a/pkg/rpcclient/waiter/waiter.go b/pkg/rpcclient/waiter/waiter.go index 95d11fdd7..d97ed3ab5 100644 --- a/pkg/rpcclient/waiter/waiter.go +++ b/pkg/rpcclient/waiter/waiter.go @@ -118,14 +118,26 @@ func errIsAlreadyExists(err error) bool { // or not an implementation of these two interfaces. It returns websocket-based // waiter, polling-based waiter or a stub correspondingly. func New(base any, v *result.Version) Waiter { + return NewCustom(base, v, PollConfig{}) +} + +// NewCustom creates Waiter instance. It can be either websocket-based or +// polling-base, otherwise Waiter stub is returned. As a first argument +// it accepts RPCEventBased implementation, RPCPollingBased implementation +// or not an implementation of these two interfaces. It returns websocket-based +// waiter, polling-based waiter or a stub correspondingly. As the second +// argument it accepts the RPC node version necessary for awaiting behaviour +// customisation. As a third argument it accepts the configuration of +// [PollingBased] [Waiter]. +func NewCustom(base any, v *result.Version, pollConfig PollConfig) Waiter { if eventW, ok := base.(RPCEventBased); ok { return &EventBased{ ws: eventW, - polling: newCustomPollingBased(eventW, v, PollConfig{}), + polling: newCustomPollingBased(eventW, v, pollConfig), } } if pollW, ok := base.(RPCPollingBased); ok { - return newCustomPollingBased(pollW, v, PollConfig{}) + return newCustomPollingBased(pollW, v, pollConfig) } return NewNull() }