[#404] morph/client: Add awaiting function

Awaiting function locks execution for N blocks.
Useful to wait for notary deposit.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-02-25 19:50:10 +03:00 committed by Alex Vanin
parent 4b10e82685
commit ddf1ac0f28
2 changed files with 62 additions and 8 deletions

View file

@ -27,15 +27,21 @@ type cfg struct {
logger *logger.Logger // logging component
gas util.Uint160 // native gas script-hash
waitInterval time.Duration
}
const defaultDialTimeout = 5 * time.Second
const (
defaultDialTimeout = 5 * time.Second
defaultWaitInterval = 500 * time.Millisecond
)
func defaultConfig() *cfg {
return &cfg{
ctx: context.Background(),
dialTimeout: defaultDialTimeout,
logger: zap.L(),
ctx: context.Background(),
dialTimeout: defaultDialTimeout,
logger: zap.L(),
waitInterval: defaultWaitInterval,
}
}
@ -95,10 +101,11 @@ func New(key *ecdsa.PrivateKey, endpoint string, opts ...Option) (*Client, error
}
return &Client{
logger: cfg.logger,
client: cli,
acc: account,
gas: gas,
logger: cfg.logger,
client: cli,
acc: account,
gas: gas,
waitInterval: cfg.waitInterval,
}, nil
}