From 870afc5193883067fa5649cfc7f2ad747b0c1f05 Mon Sep 17 00:00:00 2001 From: Leo Date: Mon, 10 Jan 2022 20:48:33 +0100 Subject: [PATCH] node/pkg/ethereum: do not override outer scope's cancel function Otherwise, we might end up cancelling the root context by accident. commit-id:09a5287e --- node/pkg/ethereum/watcher.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/pkg/ethereum/watcher.go b/node/pkg/ethereum/watcher.go index e8f0032dd..1d589e7ba 100644 --- a/node/pkg/ethereum/watcher.go +++ b/node/pkg/ethereum/watcher.go @@ -207,7 +207,7 @@ func (e *Watcher) Run(ctx context.Context) error { case ev := <-messageC: // Request timestamp for block msm := time.Now() - timeout, cancel = context.WithTimeout(ctx, 15*time.Second) + timeout, cancel := context.WithTimeout(ctx, 15*time.Second) b, err := c.BlockByNumber(timeout, big.NewInt(int64(ev.Raw.BlockNumber))) cancel() queryLatency.WithLabelValues(e.networkName, "block_by_number").Observe(time.Since(msm).Seconds()) @@ -313,7 +313,7 @@ func (e *Watcher) Run(ctx context.Context) error { // Transaction is now ready if pLock.height+uint64(expectedConfirmations) <= blockNumberU { - timeout, cancel = context.WithTimeout(ctx, 5*time.Second) + timeout, cancel := context.WithTimeout(ctx, 5*time.Second) tx, err := c.TransactionReceipt(timeout, pLock.message.TxHash) cancel()