Skip to content

Commit f17cc48

Browse files
committed
Check balance at monitoring start
We added a check execution at start of the monitoring. Previously we had to wait for ticker to invoke the first check.
1 parent 26fdfa2 commit f17cc48

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

pkg/chain/ethlike/balance_monitor.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,21 @@ func (bm *BalanceMonitor) Observe(
6363
ticker := time.NewTicker(tick)
6464
defer ticker.Stop()
6565

66+
checkBalance := func() {
67+
err := wrappers.DoWithDefaultRetry(retryTimeout, check)
68+
if err != nil {
69+
logger.Errorf("balance monitor error: [%v]", err)
70+
}
71+
}
72+
73+
// Initial balance check at monitoring start.
74+
checkBalance()
75+
6676
for {
6777
select {
78+
// Balance check at ticks.
6879
case <-ticker.C:
69-
err := wrappers.DoWithDefaultRetry(retryTimeout, check)
70-
71-
logger.Errorf("balance monitor error: [%v]", err)
80+
checkBalance()
7281
case <-ctx.Done():
7382
return
7483
}

0 commit comments

Comments
 (0)