Commit de98bbff authored by Andreas Bigger's avatar Andreas Bigger

defer cancels

parent 9699dc09
...@@ -178,8 +178,8 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (* ...@@ -178,8 +178,8 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (*
// Fetch the sender's nonce from the latest known block (nil `blockNumber`) // Fetch the sender's nonce from the latest known block (nil `blockNumber`)
childCtx, cancel := context.WithTimeout(ctx, m.Config.NetworkTimeout) childCtx, cancel := context.WithTimeout(ctx, m.Config.NetworkTimeout)
defer cancel()
nonce, err := m.backend.NonceAt(childCtx, candidate.From, nil) nonce, err := m.backend.NonceAt(childCtx, candidate.From, nil)
cancel()
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get nonce: %w", err) return nil, fmt.Errorf("failed to get nonce: %w", err)
} }
...@@ -188,8 +188,8 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (* ...@@ -188,8 +188,8 @@ func (m *SimpleTxManager) CraftTx(ctx context.Context, candidate TxCandidate) (*
// we need to try to fetch it again from the backend. // we need to try to fetch it again from the backend.
if m.chainID == nil { if m.chainID == nil {
childCtx, cancel := context.WithTimeout(ctx, m.Config.NetworkTimeout) childCtx, cancel := context.WithTimeout(ctx, m.Config.NetworkTimeout)
defer cancel()
chainID, err := m.backend.ChainID(childCtx) chainID, err := m.backend.ChainID(childCtx)
cancel()
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to get chain ID: %w", err) return nil, fmt.Errorf("failed to get chain ID: %w", 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