]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Remove temporary anti-duplicata logic
authorAntoine Riard <ariard@student.42.fr>
Mon, 9 Mar 2020 23:56:42 +0000 (19:56 -0400)
committerAntoine Riard <ariard@student.42.fr>
Fri, 17 Apr 2020 21:50:26 +0000 (17:50 -0400)
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs
lightning/src/util/test_utils.rs

index a2f9a7c3239981fb735643d5998672f6b348b28f..cf0dc1832d8598c3a2220d9856cfc4a8326abaf8 100644 (file)
@@ -1038,7 +1038,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<TestChanMonCfg> {
        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(HashMap::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 });
        }
index d45469194f25af742f252fd477c9050ded5403dc..8f140310842de5fd740cf71a72527191039b9750 100644 (file)
@@ -6792,7 +6792,7 @@ fn test_data_loss_protect() {
        let logger: Arc<Logger> = Arc::new(test_utils::TestLogger::with_id(format!("node {}", 0)));
        let mut chan_monitor = <(Sha256dHash, ChannelMonitor<EnforcingChannelKeys>)>::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(HashMap::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);
index 618cef0c2080f3b7fd9f34cdb6f0701a35ba6909..13cbde4aa1fe35c24702d277a48b310c77d08490 100644 (file)
@@ -110,24 +110,9 @@ impl<'a> channelmonitor::ManyChannelMonitor<EnforcingChannelKeys> for TestChanne
 
 pub struct TestBroadcaster {
        pub txn_broadcasted: Mutex<Vec<Transaction>>,
-       pub broadcasted_txn: Mutex<HashMap<Sha256dHash, u8>> // Temporary field while refactoring out tx duplication
 }
 impl chaininterface::BroadcasterInterface for TestBroadcaster {
        fn broadcast_transaction(&self, tx: &Transaction) {
-               let mut already = false;
-               {
-                       if let Some(counter) = self.broadcasted_txn.lock().unwrap().get_mut(&tx.txid()) {
-                               match counter {
-                                       0 => { *counter = 1; already = true }, // We still authorize at least 2 duplicata for a given TXID to account ChannelManager/ChannelMonitor broadcast
-                                       1 => return,
-                                       _ => panic!()
-                               }
-                       }
-               }
-               if !already {
-                       self.broadcasted_txn.lock().unwrap().insert(tx.txid(), 0);
-               }
-               print!("\nFRESH BROADCAST {}\n\n", tx.txid());
                self.txn_broadcasted.lock().unwrap().push(tx.clone());
        }
 }