File tree Expand file tree Collapse file tree 2 files changed +20
-7
lines changed Expand file tree Collapse file tree 2 files changed +20
-7
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 ( spending_tx) => self . wallet . broadcast_transaction ( & spending_tx) ,
567
+ Ok ( spending_tx) => self . wallet . broadcast_transactions ( & [ & spending_tx] ) ,
568
568
Err ( err) => {
569
569
log_error ! ( self . logger, "Error spending outputs: {:?}" , err) ;
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,18 +305,31 @@ 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
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 } )
316
+ locked_runtime. as_ref ( ) . unwrap ( ) . block_on ( async move {
317
+ let mut handles = Vec :: new ( ) ;
318
+ for tx in txs {
319
+ handles. push ( self . blockchain . broadcast ( tx) ) ;
320
+ }
321
+
322
+ for handle in handles {
323
+ match handle. await {
324
+ Ok ( _) => { }
325
+ Err ( err) => {
326
+ return Err ( err) ;
327
+ }
328
+ }
329
+ }
330
+
331
+ Ok ( ( ) )
332
+ } )
320
333
} ) ;
321
334
322
335
match res {
You can’t perform that action at this time.
0 commit comments