File tree Expand file tree Collapse file tree 2 files changed +20
-15
lines changed Expand file tree Collapse file tree 2 files changed +20
-15
lines changed Original file line number Diff line number Diff line change @@ -560,7 +560,7 @@ where
560
560
& Secp256k1 :: new ( ) ,
561
561
) ;
562
562
match res {
563
- Ok ( spending_tx) => self . wallet . broadcast_transaction ( & spending_tx) ,
563
+ Ok ( spending_tx) => self . wallet . broadcast_transactions ( & [ & spending_tx] ) ,
564
564
Err ( err) => {
565
565
log_error ! ( self . logger, "Error spending outputs: {:?}" , err) ;
566
566
}
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ where
252
252
psbt. extract_tx ( )
253
253
} ;
254
254
255
- self . broadcast_transaction ( & tx ) ;
255
+ self . broadcast_transactions ( & [ & tx ] ) ;
256
256
257
257
let txid = tx. txid ( ) ;
258
258
@@ -306,26 +306,31 @@ impl<D> BroadcasterInterface for Wallet<D>
306
306
where
307
307
D : BatchDatabase ,
308
308
{
309
- fn broadcast_transaction ( & self , tx : & Transaction ) {
309
+ fn broadcast_transactions ( & self , txs : & [ & Transaction ] ) {
310
310
let locked_runtime = self . runtime . read ( ) . unwrap ( ) ;
311
311
if locked_runtime. as_ref ( ) . is_none ( ) {
312
312
log_error ! ( self . logger, "Failed to broadcast transaction: No runtime." ) ;
313
313
return ;
314
314
}
315
315
316
- let res = tokio:: task:: block_in_place ( move || {
317
- locked_runtime
318
- . as_ref ( )
319
- . unwrap ( )
320
- . block_on ( async move { self . blockchain . broadcast ( tx) . await } )
321
- } ) ;
316
+ let bcast_logger = Arc :: clone ( & self . logger ) ;
317
+ tokio:: task:: block_in_place ( move || {
318
+ locked_runtime. as_ref ( ) . unwrap ( ) . block_on ( async move {
319
+ let mut handles = Vec :: new ( ) ;
320
+ for tx in txs {
321
+ handles. push ( self . blockchain . broadcast ( tx) ) ;
322
+ }
322
323
323
- match res {
324
- Ok ( _) => { }
325
- Err ( err) => {
326
- log_error ! ( self . logger, "Failed to broadcast transaction: {}" , err) ;
327
- }
328
- }
324
+ for handle in handles {
325
+ match handle. await {
326
+ Ok ( _) => { }
327
+ Err ( err) => {
328
+ log_error ! ( bcast_logger, "Failed to broadcast transaction: {}" , err) ;
329
+ }
330
+ }
331
+ }
332
+ } )
333
+ } ) ;
329
334
}
330
335
}
331
336
You can’t perform that action at this time.
0 commit comments