Kaspawallet.send(): Make separate context for Broadcast, to prolong timeout (#2131)

* Kaspawallet.send(): Make separate context for Broadcast, to prolong timeout

* Amend comment

Co-authored-by: Michael Sutton <mikisiton2@gmail.com>
This commit is contained in:
Svarog 2022-08-28 13:17:58 +03:00 committed by GitHub
parent 3286a7d010
commit 2a7e03e232
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,7 +65,12 @@ func send(conf *sendConfig) error {
fmt.Printf("Broadcasting %d transactions\n", len(signedTransactions))
}
response, err := daemonClient.Broadcast(ctx, &pb.BroadcastRequest{Transactions: signedTransactions})
// Since we waited for user input when getting the password, which could take unbound amount of time -
// create a new context for broadcast, to reset the timeout.
broadcastCtx, broadcastCancel := context.WithTimeout(context.Background(), daemonTimeout)
defer broadcastCancel()
response, err := daemonClient.Broadcast(broadcastCtx, &pb.BroadcastRequest{Transactions: signedTransactions})
if err != nil {
return err
}