Skip to content

Commit 3da69d8

Browse files
committed
f: Draw the rebroadcast tx batch at random
Co-Authored-By: HAL 9000
1 parent 4e7516b commit 3da69d8

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/wallet/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ use crate::payment::{
6363
};
6464
use crate::runtime::Runtime;
6565
use crate::types::{Broadcaster, PaymentStore, PendingPaymentStore};
66+
use crate::util::random_range;
6667
use crate::{ChainSource, Error};
6768

6869
pub(crate) enum OnchainSendAmount {
@@ -326,7 +327,7 @@ impl Wallet {
326327
}
327328

328329
if !unconfirmed_outbound_txids.is_empty() {
329-
let txs_to_broadcast: Vec<Transaction> = {
330+
let mut txs_to_broadcast: Vec<Transaction> = {
330331
let locked_wallet = self.inner.lock().expect("lock");
331332
unconfirmed_outbound_txids
332333
.iter()
@@ -337,6 +338,10 @@ impl Wallet {
337338
})
338339
.collect()
339340
};
341+
for i in (1..txs_to_broadcast.len()).rev() {
342+
let j = random_range(0, i as u64) as usize;
343+
txs_to_broadcast.swap(i, j);
344+
}
340345

341346
if !txs_to_broadcast.is_empty() {
342347
let tx_count = txs_to_broadcast.len();

0 commit comments

Comments
 (0)