Skip to content

Commit

Permalink
Fix ctx cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanTinianov committed Oct 31, 2024
1 parent 6392027 commit fe86168
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/solana/client/multinode/transaction_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ func (txSender *TransactionSender[TX, RESULT, CHAIN_ID, RPC]) SendTransaction(ct
}

txSenderCtx, cancel := txSender.chStop.NewCtx()
defer cancel()
reportWg := sync.WaitGroup{}
defer func() {
go func() {
reportWg.Wait()
cancel()
}()
}()

healthyNodesNum := 0
err := txSender.multiNode.DoAll(txSenderCtx, func(ctx context.Context, rpc RPC, isSendOnly bool) {
Expand Down Expand Up @@ -152,7 +158,11 @@ func (txSender *TransactionSender[TX, RESULT, CHAIN_ID, RPC]) SendTransaction(ct
}

txSender.wg.Add(1)
go txSender.reportSendTxAnomalies(tx, txResultsToReport)
reportWg.Add(1)
go func() {
txSender.reportSendTxAnomalies(tx, txResultsToReport)
reportWg.Done()
}()

return txSender.collectTxResults(ctx, tx, healthyNodesNum, txResults, startTime)
}
Expand Down

0 comments on commit fe86168

Please sign in to comment.