From 2a7e03e232f225811454d7dbd4119835f2711eef Mon Sep 17 00:00:00 2001 From: Svarog Date: Sun, 28 Aug 2022 13:17:58 +0300 Subject: [PATCH] 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 --- cmd/kaspawallet/send.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/kaspawallet/send.go b/cmd/kaspawallet/send.go index 9f4616c65..c4f371b32 100644 --- a/cmd/kaspawallet/send.go +++ b/cmd/kaspawallet/send.go @@ -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 }