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