Skip to content

Commit b3652f7

Browse files
author
Antoine Riard
committed
Remove TestBroadcaster temporary dedup buffer
1 parent 3a4100c commit b3652f7

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use std::cell::RefCell;
3737
use std::rc::Rc;
3838
use std::sync::{Arc, Mutex};
3939
use std::mem;
40-
use std::collections::{HashSet, HashMap};
40+
use std::collections::HashMap;
4141

4242
pub const CHAN_CONFIRM_DEPTH: u32 = 100;
4343
pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifierRef<'b>, chain: &chaininterface::ChainWatchInterfaceUtil, tx: &Transaction, chan_id: u32) {
@@ -918,8 +918,8 @@ pub fn fail_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route:
918918

919919
pub fn create_chanmon_cfgs(node_count: usize) -> Vec<TestChanMonCfg> {
920920
let mut chan_mon_cfgs = Vec::new();
921-
for _ in 0..node_count {
922-
let tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new()), broadcasted_txn: Mutex::new(HashSet::new())};
921+
for i in 0..node_count {
922+
let tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new())};
923923
chan_mon_cfgs.push(TestChanMonCfg{ tx_broadcaster });
924924
}
925925

lightning/src/ln/functional_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6556,7 +6556,7 @@ fn test_data_loss_protect() {
65566556
let logger: Arc<Logger> = Arc::new(test_utils::TestLogger::with_id(format!("node {}", 0)));
65576557
let mut chan_monitor = <(Sha256dHash, ChannelMonitor<EnforcingChannelKeys>)>::read(&mut ::std::io::Cursor::new(previous_chan_monitor_state.0), Arc::clone(&logger)).unwrap().1;
65586558
let chain_monitor = Arc::new(ChainWatchInterfaceUtil::new(Network::Testnet, Arc::clone(&logger)));
6559-
tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new()), broadcasted_txn: Mutex::new(HashSet::new())};
6559+
tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new())};
65606560
let feeest = Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 });
65616561
keys_manager = test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::clone(&logger));
65626562
monitor = test_utils::TestChannelMonitor::new(chain_monitor.clone(), &tx_broadcaster, logger.clone(), feeest.clone());

lightning/src/util/test_utils.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use secp256k1::{SecretKey, PublicKey};
2222
use std::time::{SystemTime, UNIX_EPOCH};
2323
use std::sync::{Arc,Mutex};
2424
use std::{mem};
25-
use std::collections::{HashMap, HashSet};
25+
use std::collections::HashMap;
2626

2727
pub struct TestVecWriter(pub Vec<u8>);
2828
impl Writer for TestVecWriter {
@@ -108,19 +108,9 @@ impl<'a> channelmonitor::ManyChannelMonitor<EnforcingChannelKeys> for TestChanne
108108

109109
pub struct TestBroadcaster {
110110
pub txn_broadcasted: Mutex<Vec<Transaction>>,
111-
pub broadcasted_txn: Mutex<HashSet<Sha256dHash>> // Temporary field while refactoring out tx duplication
112111
}
113112
impl chaininterface::BroadcasterInterface for TestBroadcaster {
114113
fn broadcast_transaction(&self, tx: &Transaction) {
115-
{
116-
if let Some(_) = self.broadcasted_txn.lock().unwrap().get(&tx.txid()) {
117-
// If commitment tx, HTLC-timeout or HTLC-Success, duplicate broadcast are still ok
118-
if tx.input[0].sequence == 0xfffffffd {
119-
return;
120-
}
121-
}
122-
}
123-
self.broadcasted_txn.lock().unwrap().insert(tx.txid());
124114
self.txn_broadcasted.lock().unwrap().push(tx.clone());
125115
}
126116
}

0 commit comments

Comments
 (0)