mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 09:29:38 +00:00
rpcclient: integrate customizable Waiter with Actor
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
afbb51e78c
commit
92c6361be8
2 changed files with 19 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue