Skip to content

Commit 98af8c3

Browse files
committed
f Account for BroadcasterInterface taking a slice
1 parent a1d0abc commit 98af8c3

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ where
564564
&Secp256k1::new(),
565565
);
566566
match res {
567-
Ok(spending_tx) => self.wallet.broadcast_transaction(&spending_tx),
567+
Ok(spending_tx) => self.wallet.broadcast_transactions(&[&spending_tx]),
568568
Err(err) => {
569569
log_error!(self.logger, "Error spending outputs: {:?}", err);
570570
}

src/wallet.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ where
249249
psbt.extract_tx()
250250
};
251251

252-
self.broadcast_transaction(&tx);
252+
self.broadcast_transactions(&[&tx]);
253253

254254
let txid = tx.txid();
255255

@@ -305,18 +305,31 @@ where
305305
D: BatchDatabase,
306306
L::Target: Logger,
307307
{
308-
fn broadcast_transaction(&self, tx: &Transaction) {
308+
fn broadcast_transactions(&self, txs: &[&Transaction]) {
309309
let locked_runtime = self.runtime.read().unwrap();
310310
if locked_runtime.as_ref().is_none() {
311311
log_error!(self.logger, "Failed to broadcast transaction: No runtime.");
312312
return;
313313
}
314314

315315
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+
})
320333
});
321334

322335
match res {

0 commit comments

Comments
 (0)