cmd/wavelet: have all transaction broadcasts be async
@@ -268,19 +268,21 @@ func main() {
log.Fatal().Err(err).Msg("Failed to convert staking amount to a uint64.")
}
+ go func() {
tx, err := ledger.NewTransaction(n.Keys, sys.TagStake, payload.NewWriter(nil).WriteUint64(uint64(amount)).Bytes())
if err != nil {
log.Error().Err(err).Msg("Failed to create a stake placement transaction.")
- continue
+ return
}
err = node.BroadcastTransaction(n, tx)
if err != nil {
log.Error().Err(err).Msg("An error occurred while broadcasting a stake placement transaction.")
- continue
+ return
}
log.Info().Msgf("Success! Your stake placement transaction ID: %x", tx.ID)
+ }()
case "ws":
if len(cmd) < 2 {
continue
@@ -291,19 +293,21 @@ func main() {
log.Fatal().Err(err).Msg("Failed to convert withdraw amount to an uint64.")
}
+ go func() {
tx, err := ledger.NewTransaction(n.Keys, sys.TagStake, payload.NewWriter(nil).WriteUint64(uint64(amount)).Bytes())
if err != nil {
log.Error().Err(err).Msg("Failed to create a stake withdrawal transaction.")
- continue
+ return
}
err = node.BroadcastTransaction(n, tx)
if err != nil {
log.Error().Err(err).Msg("An error occurred while broadcasting a stake withdrawal transaction.")
- continue
+ return
}
log.Info().Msgf("Success! Your stake withdrawal transaction ID: %x", tx.ID)
+ }()
case "c":
if len(cmd) < 2 {
continue
@@ -318,19 +322,21 @@ func main() {
continue
}
+ go func() {
tx, err := ledger.NewTransaction(n.Keys, sys.TagContract, code)
if err != nil {
log.Error().Err(err).Msg("Failed to create a smart contract creation transaction.")
- continue
+ return
}
err = node.BroadcastTransaction(n, tx)
if err != nil {
log.Error().Err(err).Msg("An error occurred while broadcasting a smart contract creation transaction.")
- continue
+ return
}
log.Info().Msgf("Success! Your smart contract ID: %x", tx.ID)
+ }()
}
}
}
