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
560560 & Secp256k1 :: new ( ) ,
561561 ) ;
562562 match res {
563- Ok ( spending_tx) => self . wallet . broadcast_transaction ( & spending_tx) ,
563+ Ok ( spending_tx) => self . wallet . broadcast_transactions ( & [ & spending_tx] ) ,
564564 Err ( err) => {
565565 log_error ! ( self . logger, "Error spending outputs: {:?}" , err) ;
566566 }
Original file line number Diff line number Diff line change @@ -252,7 +252,7 @@ where
252252 psbt. extract_tx ( )
253253 } ;
254254
255- self . broadcast_transaction ( & tx ) ;
255+ self . broadcast_transactions ( & [ & tx ] ) ;
256256
257257 let txid = tx. txid ( ) ;
258258
@@ -306,26 +306,31 @@ impl<D> BroadcasterInterface for Wallet<D>
306306where
307307 D : BatchDatabase ,
308308{
309- fn broadcast_transaction ( & self , tx : & Transaction ) {
309+ fn broadcast_transactions ( & self , txs : & [ & Transaction ] ) {
310310 let locked_runtime = self . runtime . read ( ) . unwrap ( ) ;
311311 if locked_runtime. as_ref ( ) . is_none ( ) {
312312 log_error ! ( self . logger, "Failed to broadcast transaction: No runtime." ) ;
313313 return ;
314314 }
315315
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+ }
322323
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+ } ) ;
329334 }
330335}
331336
You can’t perform that action at this time.
0 commit comments