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) {
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(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 });
}
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(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);
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<u8>);
impl Writer for TestVecWriter {
pub struct TestBroadcaster {
pub txn_broadcasted: Mutex<Vec<Transaction>>,
- pub broadcasted_txn: Mutex<HashSet<Sha256dHash>> // 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());
}
}