From: Antoine Riard Date: Fri, 24 Jan 2020 22:48:27 +0000 (-0500) Subject: Remove TestBroadcaster temporary dedup buffer X-Git-Tag: v0.0.12~110^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=d86423c36607e5d83cb455796916045d60cb7d2a;p=rust-lightning Remove TestBroadcaster temporary dedup buffer --- diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 655e3681d..a86fb527e 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -37,7 +37,7 @@ use std::cell::RefCell; use std::rc::Rc; use std::sync::{Arc, Mutex}; use std::mem; -use std::collections::{HashSet, HashMap}; +use std::collections::HashMap; pub const CHAN_CONFIRM_DEPTH: u32 = 100; pub fn confirm_transaction<'a, 'b: 'a>(notifier: &'a chaininterface::BlockNotifierRef<'b>, chain: &chaininterface::ChainWatchInterfaceUtil, tx: &Transaction, chan_id: u32) { @@ -950,7 +950,7 @@ pub fn fail_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: pub fn create_chanmon_cfgs(node_count: usize) -> Vec { let mut chan_mon_cfgs = Vec::new(); for _ in 0..node_count { - let tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new()), broadcasted_txn: Mutex::new(HashSet::new())}; + let tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new())}; let fee_estimator = test_utils::TestFeeEstimator { sat_per_kw: 253 }; chan_mon_cfgs.push(TestChanMonCfg{ tx_broadcaster, fee_estimator }); } diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 7ba3675fa..3ba295cbf 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -6563,7 +6563,7 @@ fn test_data_loss_protect() { let logger: Arc = Arc::new(test_utils::TestLogger::with_id(format!("node {}", 0))); let mut chan_monitor = <(Sha256dHash, ChannelMonitor)>::read(&mut ::std::io::Cursor::new(previous_chan_monitor_state.0), Arc::clone(&logger)).unwrap().1; let chain_monitor = Arc::new(ChainWatchInterfaceUtil::new(Network::Testnet, Arc::clone(&logger))); - tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new()), broadcasted_txn: Mutex::new(HashSet::new())}; + tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new())}; fee_estimator = test_utils::TestFeeEstimator { sat_per_kw: 253 }; keys_manager = test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::clone(&logger)); monitor = test_utils::TestChannelMonitor::new(chain_monitor.clone(), &tx_broadcaster, logger.clone(), &fee_estimator); diff --git a/lightning/src/util/test_utils.rs b/lightning/src/util/test_utils.rs index 9af8d5cf2..78b81fa63 100644 --- a/lightning/src/util/test_utils.rs +++ b/lightning/src/util/test_utils.rs @@ -22,7 +22,7 @@ use secp256k1::{SecretKey, PublicKey}; use std::time::{SystemTime, UNIX_EPOCH}; use std::sync::{Arc,Mutex}; use std::{mem}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; pub struct TestVecWriter(pub Vec); impl Writer for TestVecWriter { @@ -108,19 +108,9 @@ impl<'a> channelmonitor::ManyChannelMonitor for TestChanne pub struct TestBroadcaster { pub txn_broadcasted: Mutex>, - pub broadcasted_txn: Mutex> // Temporary field while refactoring out tx duplication } impl chaininterface::BroadcasterInterface for TestBroadcaster { fn broadcast_transaction(&self, tx: &Transaction) { - { - if let Some(_) = self.broadcasted_txn.lock().unwrap().get(&tx.txid()) { - // If commitment tx, HTLC-timeout or HTLC-Success, duplicate broadcast are still ok - if tx.input[0].sequence == 0xfffffffd { - return; - } - } - } - self.broadcasted_txn.lock().unwrap().insert(tx.txid()); self.txn_broadcasted.lock().unwrap().push(tx.clone()); } }