Commit 9032b605 authored by Kien Trinh's avatar Kien Trinh Committed by GitHub

perf(op-service/dial/rollup_sync): init timer outside of the loop (#10990)

* perf: use go ticker to handle time management in rollup sync

* fix: ticker does not accept no negative value

* bet
parent 43b1c4c0
......@@ -15,6 +15,9 @@ func WaitRollupSync(
l1BlockTarget uint64,
pollInterval time.Duration,
) error {
timer := time.NewTimer(pollInterval)
defer timer.Stop()
for {
syncst, err := rollup.SyncStatus(ctx)
if err != nil {
......@@ -29,12 +32,12 @@ func WaitRollupSync(
}
lgr.Info("rollup current L1 block still behind target, retrying")
timer := time.NewTimer(pollInterval)
timer.Reset(pollInterval)
select {
case <-timer.C: // next try
case <-ctx.Done():
lgr.Warn("waiting for rollup sync timed out")
timer.Stop()
return ctx.Err()
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment