File tree Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Expand file tree Collapse file tree 2 files changed +24
-13
lines changed Original file line number Diff line number Diff line change @@ -564,7 +564,7 @@ where
564
564
& Secp256k1 :: new ( ) ,
565
565
) ;
566
566
match res {
567
- Ok ( Some ( spending_tx) ) => self . wallet . broadcast_transaction ( & spending_tx) ,
567
+ Ok ( Some ( spending_tx) ) => self . wallet . broadcast_transactions ( & [ & spending_tx] ) ,
568
568
Ok ( None ) => {
569
569
log_debug ! ( self . logger, "Omitted spending static outputs: {:?}" , outputs) ;
570
570
}
Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ where
249
249
psbt. extract_tx ( )
250
250
} ;
251
251
252
- self . broadcast_transaction ( & tx ) ;
252
+ self . broadcast_transactions ( & [ & tx ] ) ;
253
253
254
254
let txid = tx. txid ( ) ;
255
255
@@ -305,25 +305,36 @@ where
305
305
D : BatchDatabase ,
306
306
L :: Target : Logger ,
307
307
{
308
- fn broadcast_transaction ( & self , tx : & Transaction ) {
308
+ fn broadcast_transactions ( & self , txs : & [ & Transaction ] ) {
309
309
let locked_runtime = self . runtime . read ( ) . unwrap ( ) ;
310
310
if locked_runtime. as_ref ( ) . is_none ( ) {
311
311
log_error ! ( self . logger, "Failed to broadcast transaction: No runtime." ) ;
312
312
return ;
313
313
}
314
314
315
- let res = tokio:: task:: block_in_place ( move || {
316
- locked_runtime
317
- . as_ref ( )
318
- . unwrap ( )
319
- . block_on ( async move { self . blockchain . broadcast ( tx) . await } )
315
+ let errors = tokio:: task:: block_in_place ( move || {
316
+ locked_runtime. as_ref ( ) . unwrap ( ) . block_on ( async move {
317
+ let mut handles = Vec :: new ( ) ;
318
+ let mut errors = Vec :: new ( ) ;
319
+
320
+ for tx in txs {
321
+ handles. push ( self . blockchain . broadcast ( tx) ) ;
322
+ }
323
+
324
+ for handle in handles {
325
+ match handle. await {
326
+ Ok ( _) => { }
327
+ Err ( e) => {
328
+ errors. push ( e) ;
329
+ }
330
+ }
331
+ }
332
+ errors
333
+ } )
320
334
} ) ;
321
335
322
- match res {
323
- Ok ( _) => { }
324
- Err ( err) => {
325
- log_error ! ( self . logger, "Failed to broadcast transaction: {}" , err) ;
326
- }
336
+ for e in errors {
337
+ log_error ! ( self . logger, "Failed to broadcast transaction: {}" , e) ;
327
338
}
328
339
}
329
340
}
You can’t perform that action at this time.
0 commit comments