From f561847ad6aede44aea309084b28d363fdc3aa9e Mon Sep 17 00:00:00 2001 From: maskpp Date: Wed, 20 Mar 2024 11:20:08 +0800 Subject: [PATCH] fix(cmd): fix some context close issues (#650) --- driver/driver.go | 7 +++++-- pkg/chain_iterator/block_batch_iterator.go | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/driver/driver.go b/driver/driver.go index 36b1d1ca8..07f728512 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -122,7 +122,10 @@ func (d *Driver) eventLoop() { // doSyncWithBackoff performs a synchronising operation with a backoff strategy. doSyncWithBackoff := func() { - if err := backoff.Retry(d.doSync, backoff.NewConstantBackOff(d.RetryInterval)); err != nil { + if err := backoff.Retry( + d.doSync, + backoff.WithContext(backoff.NewConstantBackOff(d.RetryInterval), d.ctx), + ); err != nil { log.Error("Sync L2 execution engine's block chain error", "error", err) } } @@ -192,7 +195,7 @@ func (d *Driver) reportProtocolStatus() { maxNumBlocks = configs.BlockMaxProposals return nil }, - backoff.NewConstantBackOff(d.RetryInterval), + backoff.WithContext(backoff.NewConstantBackOff(d.RetryInterval), d.ctx), ); err != nil { log.Error("Failed to get protocol state variables", "error", err) return diff --git a/pkg/chain_iterator/block_batch_iterator.go b/pkg/chain_iterator/block_batch_iterator.go index 72cccf169..e33c09393 100644 --- a/pkg/chain_iterator/block_batch_iterator.go +++ b/pkg/chain_iterator/block_batch_iterator.go @@ -156,7 +156,7 @@ func (i *BlockBatchIterator) Iter() error { return nil } - if err := backoff.Retry(iterOp, backoff.NewConstantBackOff(i.retryInterval)); err != nil { + if err := backoff.Retry(iterOp, backoff.WithContext(backoff.NewConstantBackOff(i.retryInterval), i.ctx)); err != nil { return err }