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
This commit is contained in:
Leo 2022-01-10 20:48:33 +01:00 committed by Leopold Schabel
parent a5223c074a
commit 870afc5193
1 changed files with 2 additions and 2 deletions

View File

@ -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()