mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 06:25:55 +00:00
Fix prints and use batches also for send operation
This commit is contained in:
parent
ee5dacc72e
commit
e2cb414301
@ -42,6 +42,15 @@ func broadcast(conf *broadcastConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
err = broadcastInBatches(ctx, daemonClient, transactions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func broadcastInBatches(ctx context.Context, daemonClient pb.KaspawalletdClient, transactions [][]byte) error {
|
||||
const batch = 50
|
||||
position := 0
|
||||
|
||||
@ -57,8 +66,10 @@ func broadcast(conf *broadcastConfig) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if position == 0 {
|
||||
if position == 0 && position+batch >= len(transactions) {
|
||||
fmt.Println("Transactions were sent successfully")
|
||||
} else {
|
||||
fmt.Println("Transaction batch was sent successfully")
|
||||
}
|
||||
fmt.Println("Transaction ID(s): ")
|
||||
for _, txID := range response.TxIDs {
|
||||
@ -66,6 +77,5 @@ func broadcast(conf *broadcastConfig) error {
|
||||
}
|
||||
position += batch
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -64,15 +64,10 @@ func send(conf *sendConfig) error {
|
||||
fmt.Printf("Broadcasting %d transactions\n", len(signedTransactions))
|
||||
}
|
||||
|
||||
response, err := daemonClient.Broadcast(ctx, &pb.BroadcastRequest{Transactions: signedTransactions})
|
||||
err = broadcastInBatches(ctx, daemonClient, signedTransactions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("Transactions were sent successfully")
|
||||
fmt.Println("Transaction ID(s): ")
|
||||
for _, txID := range response.TxIDs {
|
||||
fmt.Printf("\t%s\n", txID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user