From bff9982299921751edaaa208824890036aa12900 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Wed, 26 Feb 2020 16:00:26 -0500 Subject: [PATCH] multi: update ChannelManager's keys manager from Arc to Deref --- fuzz/src/chanmon_consistency.rs | 2 +- fuzz/src/full_stack.rs | 8 ++-- lightning/src/ln/channel.rs | 9 +++- lightning/src/ln/channelmanager.rs | 52 +++++++++++++++-------- lightning/src/ln/functional_test_utils.rs | 22 +++++----- lightning/src/ln/functional_tests.rs | 33 ++++++++------ lightning/src/ln/peer_handler.rs | 2 +- 7 files changed, 77 insertions(+), 51 deletions(-) diff --git a/fuzz/src/chanmon_consistency.rs b/fuzz/src/chanmon_consistency.rs index dc811c3ba..cc7c33f04 100644 --- a/fuzz/src/chanmon_consistency.rs +++ b/fuzz/src/chanmon_consistency.rs @@ -233,7 +233,7 @@ pub fn do_test(data: &[u8]) { channel_monitors: &mut monitor_refs, }; - (<(Sha256d, ChannelManager, Arc>)>::read(&mut Cursor::new(&$ser.0), read_args).expect("Failed to read manager").1, monitor) + (<(Sha256d, ChannelManager, Arc, Arc>)>::read(&mut Cursor::new(&$ser.0), read_args).expect("Failed to read manager").1, monitor) } } } diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs index abe542f60..3b323ea7c 100644 --- a/fuzz/src/full_stack.rs +++ b/fuzz/src/full_stack.rs @@ -136,9 +136,9 @@ impl<'a> Hash for Peer<'a> { } struct MoneyLossDetector<'a> { - manager: Arc>>, Arc>>, + manager: Arc>>, Arc, Arc>>, monitor: Arc>>, - handler: PeerManager, Arc>>, Arc>>>, + handler: PeerManager, Arc>>, Arc, Arc>>>, peers: &'a RefCell<[bool; 256]>, funding_txn: Vec, @@ -150,9 +150,9 @@ struct MoneyLossDetector<'a> { } impl<'a> MoneyLossDetector<'a> { pub fn new(peers: &'a RefCell<[bool; 256]>, - manager: Arc>>, Arc>>, + manager: Arc>>, Arc, Arc>>, monitor: Arc>>, - handler: PeerManager, Arc>>, Arc>>>) -> Self { + handler: PeerManager, Arc>>, Arc, Arc>>>) -> Self { MoneyLossDetector { manager, monitor, diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index c503aaea6..df4cea4e1 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -35,6 +35,7 @@ use std; use std::default::Default; use std::{cmp,mem,fmt}; use std::sync::{Arc}; +use std::ops::Deref; #[cfg(test)] pub struct ChannelValueStat { @@ -437,7 +438,9 @@ impl Channel { } // Constructors: - pub fn new_outbound(fee_estimator: &FeeEstimator, keys_provider: &Arc>, their_node_id: PublicKey, channel_value_satoshis: u64, push_msat: u64, user_id: u64, logger: Arc, config: &UserConfig) -> Result, APIError> { + pub fn new_outbound(fee_estimator: &FeeEstimator, keys_provider: &K, their_node_id: PublicKey, channel_value_satoshis: u64, push_msat: u64, user_id: u64, logger: Arc, config: &UserConfig) -> Result, APIError> + where K::Target: KeysInterface + { let chan_keys = keys_provider.get_channel_keys(false, channel_value_satoshis); if channel_value_satoshis >= MAX_FUNDING_SATOSHIS { @@ -550,7 +553,9 @@ impl Channel { /// Creates a new channel from a remote sides' request for one. /// Assumes chain_hash has already been checked and corresponds with what we expect! - pub fn new_from_req(fee_estimator: &FeeEstimator, keys_provider: &Arc>, their_node_id: PublicKey, their_features: InitFeatures, msg: &msgs::OpenChannel, user_id: u64, logger: Arc, config: &UserConfig) -> Result, ChannelError> { + pub fn new_from_req(fee_estimator: &FeeEstimator, keys_provider: &K, their_node_id: PublicKey, their_features: InitFeatures, msg: &msgs::OpenChannel, user_id: u64, logger: Arc, config: &UserConfig) -> Result, ChannelError> + where K::Target: KeysInterface + { let mut chan_keys = keys_provider.get_channel_keys(true, msg.funding_satoshis); let their_pubkeys = ChannelPublicKeys { funding_pubkey: msg.funding_pubkey, diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 3e4d3df9a..fa71fee37 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -34,7 +34,7 @@ use ln::features::InitFeatures; use ln::msgs; use ln::onion_utils; use ln::msgs::{ChannelMessageHandler, DecodeError, LightningError}; -use chain::keysinterface::{ChannelKeys, KeysInterface, InMemoryChannelKeys}; +use chain::keysinterface::{ChannelKeys, KeysInterface, KeysManager, InMemoryChannelKeys}; use util::config::UserConfig; use util::{byte_utils, events}; use util::ser::{Readable, ReadableArgs, Writeable, Writer}; @@ -292,16 +292,20 @@ const ERR: () = "You need at least 32 bit pointers (well, usize, but we'll assum /// when you're using lightning-net-tokio (since tokio::spawn requires parameters with static /// lifetimes). Other times you can afford a reference, which is more efficient, in which case /// SimpleRefChannelManager is the more appropriate type. Defining these type aliases prevents -/// issues such as overly long function definitions. -pub type SimpleArcChannelManager = Arc, Arc>>; +/// issues such as overly long function definitions. Note that the ChannelManager can take any +/// type that implements KeysInterface for its keys manager, but this type alias chooses the +/// concrete type of the KeysManager. +pub type SimpleArcChannelManager = Arc, Arc, Arc>>; /// SimpleRefChannelManager is a type alias for a ChannelManager reference, and is the reference /// counterpart to the SimpleArcChannelManager type alias. Use this type by default when you don't /// need a ChannelManager with a static lifetime. You'll need a static lifetime in cases such as /// usage of lightning-net-tokio (since tokio::spawn requires parameters with static lifetimes). /// But if this is not necessary, using a reference is more efficient. Defining these type aliases -/// helps with issues such as long function definitions. -pub type SimpleRefChannelManager<'a, 'b, M, T> = ChannelManager; +/// helps with issues such as long function definitions. Note that the ChannelManager can take any +/// type that implements KeysInterface for its keys manager, but this type alias chooses the +/// concrete type of the KeysManager. +pub type SimpleRefChannelManager<'a, 'b, 'c, M, T> = ChannelManager; /// Manager which keeps track of a number of channels and sends messages to the appropriate /// channel, also tracking HTLC preimages and forwarding onion packets appropriately. @@ -339,9 +343,10 @@ pub type SimpleRefChannelManager<'a, 'b, M, T> = ChannelManager +pub struct ChannelManager where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { default_configuration: UserConfig, genesis_hash: Sha256dHash, @@ -376,7 +381,7 @@ pub struct ChannelManager /// Taken first everywhere where we are making changes before any other locks. total_consistency_lock: RwLock<()>, - keys_manager: Arc>, + keys_manager: K, logger: Arc, } @@ -612,9 +617,10 @@ macro_rules! maybe_break_monitor_err { } } -impl ChannelManager +impl ChannelManager where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { /// Constructs a new ChannelManager to hold several channels and route between them. /// @@ -634,7 +640,7 @@ impl ChannelManager, monitor: M, tx_broadcaster: T, logger: Arc,keys_manager: Arc>, config: UserConfig, current_blockchain_height: usize) -> Result, secp256k1::Error> { + pub fn new(network: Network, feeest: Arc, monitor: M, tx_broadcaster: T, logger: Arc, keys_manager: K, config: UserConfig, current_blockchain_height: usize) -> Result, secp256k1::Error> { let secp_ctx = Secp256k1::new(); let res = ChannelManager { @@ -2563,9 +2569,10 @@ impl ChannelManager events::MessageSendEventsProvider for ChannelManager +impl events::MessageSendEventsProvider for ChannelManager where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { fn get_and_clear_pending_msg_events(&self) -> Vec { // TODO: Event release to users and serialization is currently race-y: it's very easy for a @@ -2591,9 +2598,10 @@ impl events::MessageSendEventsProvi } } -impl events::EventsProvider for ChannelManager +impl events::EventsProvider for ChannelManager where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { fn get_and_clear_pending_events(&self) -> Vec { // TODO: Event release to users and serialization is currently race-y: it's very easy for a @@ -2619,9 +2627,11 @@ impl events::EventsProvider for Cha } } -impl ChainListener for ChannelManager +impl + ChainListener for ChannelManager where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]) { let header_hash = header.bitcoin_hash(); @@ -2739,9 +2749,11 @@ impl Ch } } -impl ChannelMessageHandler for ChannelManager +impl + ChannelMessageHandler for ChannelManager where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { fn handle_open_channel(&self, their_node_id: &PublicKey, their_features: InitFeatures, msg: &msgs::OpenChannel) { let _ = self.total_consistency_lock.read().unwrap(); @@ -3212,9 +3224,10 @@ impl Readable for HTLCForwardInfo { } } -impl Writeable for ChannelManager +impl Writeable for ChannelManager where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { fn write(&self, writer: &mut W) -> Result<(), ::std::io::Error> { let _ = self.total_consistency_lock.write().unwrap(); @@ -3286,14 +3299,15 @@ impl Writeable for Chan /// 5) Move the ChannelMonitors into your local ManyChannelMonitor. /// 6) Disconnect/connect blocks on the ChannelManager. /// 7) Register the new ChannelManager with your ChainWatchInterface. -pub struct ChannelManagerReadArgs<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T: Deref> +pub struct ChannelManagerReadArgs<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T: Deref, K: Deref> where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { /// The keys provider which will give us relevant keys. Some keys will be loaded during /// deserialization. - pub keys_manager: Arc>, + pub keys_manager: K, /// The fee_estimator for use in the ChannelManager in the future. /// @@ -3330,11 +3344,13 @@ pub struct ChannelManagerReadArgs<'a, ChanSigner: 'a + ChannelKeys, M: Deref, T: pub channel_monitors: &'a mut HashMap>, } -impl<'a, R : ::std::io::Read, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref> ReadableArgs> for (Sha256dHash, ChannelManager) +impl<'a, R : ::std::io::Read, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref> + ReadableArgs> for (Sha256dHash, ChannelManager) where M::Target: ManyChannelMonitor, T::Target: BroadcasterInterface, + K::Target: KeysInterface, { - fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, ChanSigner, M, T>) -> Result { + fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, ChanSigner, M, T, K>) -> Result { let _ver: u8 = Readable::read(reader)?; let min_ver: u8 = Readable::read(reader)?; if min_ver > SERIALIZATION_VERSION { diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs index 2c1426181..ace7a9340 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -69,7 +69,7 @@ pub struct NodeCfg<'a> { pub tx_broadcaster: &'a test_utils::TestBroadcaster, pub fee_estimator: Arc, pub chan_monitor: test_utils::TestChannelMonitor<'a>, - pub keys_manager: Arc, + pub keys_manager: test_utils::TestKeysInterface, pub logger: Arc, pub node_seed: [u8; 32], } @@ -79,8 +79,8 @@ pub struct Node<'a, 'b: 'a, 'c: 'b> { pub chain_monitor: Arc, pub tx_broadcaster: &'c test_utils::TestBroadcaster, pub chan_monitor: &'b test_utils::TestChannelMonitor<'c>, - pub keys_manager: Arc, - pub node: &'a ChannelManager, &'c test_utils::TestBroadcaster>, + pub keys_manager: &'b test_utils::TestKeysInterface, + pub node: &'a ChannelManager, &'c test_utils::TestBroadcaster, &'b test_utils::TestKeysInterface>, pub router: Router, pub node_seed: [u8; 32], pub network_payment_count: Rc>, @@ -120,9 +120,9 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> { let mut w = test_utils::TestVecWriter(Vec::new()); self.node.write(&mut w).unwrap(); - <(Sha256d, ChannelManager)>::read(&mut ::std::io::Cursor::new(w.0), ChannelManagerReadArgs { + <(Sha256d, ChannelManager)>::read(&mut ::std::io::Cursor::new(w.0), ChannelManagerReadArgs { default_config: UserConfig::default(), - keys_manager: self.keys_manager.clone(), + keys_manager: self.keys_manager, fee_estimator: Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 }), monitor: self.chan_monitor, tx_broadcaster: self.tx_broadcaster.clone(), @@ -918,7 +918,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 i in 0..node_count { + for _ in 0..node_count { let tx_broadcaster = test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new()), broadcasted_txn: Mutex::new(HashSet::new())}; chan_mon_cfgs.push(TestChanMonCfg{ tx_broadcaster }); } @@ -936,7 +936,7 @@ pub fn create_node_cfgs<'a>(node_count: usize, chanmon_cfgs: &'a Vec)); let mut seed = [0; 32]; rng.fill_bytes(&mut seed); - let keys_manager = Arc::new(test_utils::TestKeysInterface::new(&seed, Network::Testnet, logger.clone() as Arc)); + let keys_manager = test_utils::TestKeysInterface::new(&seed, Network::Testnet, logger.clone() as Arc); let chan_monitor = test_utils::TestChannelMonitor::new(chain_monitor.clone(), &chanmon_cfgs[i].tx_broadcaster, logger.clone(), fee_estimator.clone()); nodes.push(NodeCfg { chain_monitor, logger, tx_broadcaster: &chanmon_cfgs[i].tx_broadcaster, fee_estimator, chan_monitor, keys_manager, node_seed: seed }); } @@ -944,20 +944,20 @@ pub fn create_node_cfgs<'a>(node_count: usize, chanmon_cfgs: &'a Vec(node_count: usize, cfgs: &'a Vec>, node_config: &[Option]) -> Vec, &'b test_utils::TestBroadcaster>> { +pub fn create_node_chanmgrs<'a, 'b>(node_count: usize, cfgs: &'a Vec>, node_config: &[Option]) -> Vec, &'b test_utils::TestBroadcaster, &'a test_utils::TestKeysInterface>> { let mut chanmgrs = Vec::new(); for i in 0..node_count { let mut default_config = UserConfig::default(); default_config.channel_options.announced_channel = true; default_config.peer_channel_config_limits.force_announced_channel_preference = false; - let node = ChannelManager::new(Network::Testnet, cfgs[i].fee_estimator.clone(), &cfgs[i].chan_monitor, cfgs[i].tx_broadcaster, cfgs[i].logger.clone(), cfgs[i].keys_manager.clone(), if node_config[i].is_some() { node_config[i].clone().unwrap() } else { default_config }, 0).unwrap(); + let node = ChannelManager::new(Network::Testnet, cfgs[i].fee_estimator.clone(), &cfgs[i].chan_monitor, cfgs[i].tx_broadcaster, cfgs[i].logger.clone(), &cfgs[i].keys_manager, if node_config[i].is_some() { node_config[i].clone().unwrap() } else { default_config }, 0).unwrap(); chanmgrs.push(node); } chanmgrs } -pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec>, chan_mgrs: &'a Vec, &'c test_utils::TestBroadcaster>>) -> Vec> { +pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec>, chan_mgrs: &'a Vec, &'c test_utils::TestBroadcaster, &'b test_utils::TestKeysInterface>>) -> Vec> { let secp_ctx = Secp256k1::new(); let mut nodes = Vec::new(); let chan_count = Rc::new(RefCell::new(0)); @@ -970,7 +970,7 @@ pub fn create_network<'a, 'b: 'a, 'c: 'b>(node_count: usize, cfgs: &'b Vec); nodes.push(Node{ chain_monitor: cfgs[i].chain_monitor.clone(), block_notifier, tx_broadcaster: cfgs[i].tx_broadcaster, chan_monitor: &cfgs[i].chan_monitor, - keys_manager: cfgs[i].keys_manager.clone(), node: &chan_mgrs[i], router, + keys_manager: &cfgs[i].keys_manager, node: &chan_mgrs[i], router, node_seed: cfgs[i].node_seed, network_chan_count: chan_count.clone(), network_payment_count: payment_count.clone(), logger: cfgs[i].logger.clone(), }) diff --git a/lightning/src/ln/functional_tests.rs b/lightning/src/ln/functional_tests.rs index 501203569..85eaa4ba1 100644 --- a/lightning/src/ln/functional_tests.rs +++ b/lightning/src/ln/functional_tests.rs @@ -3674,7 +3674,8 @@ fn test_no_txn_manager_serialize_deserialize() { let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); let new_chan_monitor: test_utils::TestChannelMonitor; - let nodes_0_deserialized: ChannelManager; + let keys_manager: test_utils::TestKeysInterface; + let nodes_0_deserialized: ChannelManager; let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); let tx = create_chan_between_nodes_with_value_init(&nodes[0], &nodes[1], 100000, 10001, InitFeatures::supported(), InitFeatures::supported()); @@ -3693,13 +3694,13 @@ fn test_no_txn_manager_serialize_deserialize() { let mut nodes_0_read = &nodes_0_serialized[..]; let config = UserConfig::default(); - let keys_manager = Arc::new(test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::new(test_utils::TestLogger::new()))); + keys_manager = test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::new(test_utils::TestLogger::new())); let (_, nodes_0_deserialized_tmp) = { let mut channel_monitors = HashMap::new(); channel_monitors.insert(chan_0_monitor.get_funding_txo().unwrap(), &mut chan_0_monitor); - <(Sha256dHash, ChannelManager)>::read(&mut nodes_0_read, ChannelManagerReadArgs { + <(Sha256dHash, ChannelManager)>::read(&mut nodes_0_read, ChannelManagerReadArgs { default_config: config, - keys_manager, + keys_manager: &keys_manager, fee_estimator: Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 }), monitor: nodes[0].chan_monitor, tx_broadcaster: nodes[0].tx_broadcaster.clone(), @@ -3743,7 +3744,8 @@ fn test_simple_manager_serialize_deserialize() { let node_cfgs = create_node_cfgs(2, &chanmon_cfgs); let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]); let new_chan_monitor: test_utils::TestChannelMonitor; - let nodes_0_deserialized: ChannelManager; + let keys_manager: test_utils::TestKeysInterface; + let nodes_0_deserialized: ChannelManager; let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs); create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::supported(), InitFeatures::supported()); @@ -3763,13 +3765,13 @@ fn test_simple_manager_serialize_deserialize() { assert!(chan_0_monitor_read.is_empty()); let mut nodes_0_read = &nodes_0_serialized[..]; - let keys_manager = Arc::new(test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::new(test_utils::TestLogger::new()))); + keys_manager = test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::new(test_utils::TestLogger::new())); let (_, nodes_0_deserialized_tmp) = { let mut channel_monitors = HashMap::new(); channel_monitors.insert(chan_0_monitor.get_funding_txo().unwrap(), &mut chan_0_monitor); - <(Sha256dHash, ChannelManager)>::read(&mut nodes_0_read, ChannelManagerReadArgs { + <(Sha256dHash, ChannelManager)>::read(&mut nodes_0_read, ChannelManagerReadArgs { default_config: UserConfig::default(), - keys_manager, + keys_manager: &keys_manager, fee_estimator: Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 }), monitor: nodes[0].chan_monitor, tx_broadcaster: nodes[0].tx_broadcaster.clone(), @@ -3797,7 +3799,8 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() { let node_cfgs = create_node_cfgs(4, &chanmon_cfgs); let node_chanmgrs = create_node_chanmgrs(4, &node_cfgs, &[None, None, None, None]); let new_chan_monitor: test_utils::TestChannelMonitor; - let nodes_0_deserialized: ChannelManager; + let keys_manager: test_utils::TestKeysInterface; + let nodes_0_deserialized: ChannelManager; let mut nodes = create_network(4, &node_cfgs, &node_chanmgrs); create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::supported(), InitFeatures::supported()); create_announced_chan_between_nodes(&nodes, 2, 0, InitFeatures::supported(), InitFeatures::supported()); @@ -3833,10 +3836,10 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() { } let mut nodes_0_read = &nodes_0_serialized[..]; - let keys_manager = Arc::new(test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::new(test_utils::TestLogger::new()))); - let (_, nodes_0_deserialized_tmp) = <(Sha256dHash, ChannelManager)>::read(&mut nodes_0_read, ChannelManagerReadArgs { + keys_manager = test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::new(test_utils::TestLogger::new())); + let (_, nodes_0_deserialized_tmp) = <(Sha256dHash, ChannelManager)>::read(&mut nodes_0_read, ChannelManagerReadArgs { default_config: UserConfig::default(), - keys_manager, + keys_manager: &keys_manager, fee_estimator: Arc::new(test_utils::TestFeeEstimator { sat_per_kw: 253 }), monitor: nodes[0].chan_monitor, tx_broadcaster: nodes[0].tx_broadcaster.clone(), @@ -6535,6 +6538,7 @@ fn test_data_loss_protect() { // * we don't broadcast our Local Commitment Tx in case of fallen behind // * we close channel in case of detecting other being fallen behind // * we are able to claim our own outputs thanks to remote my_current_per_commitment_point + let keys_manager; let tx_broadcaster; let monitor; let node_state_0; @@ -6562,12 +6566,13 @@ fn test_data_loss_protect() { 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())}; let feeest = Arc::new(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(), feeest.clone()); node_state_0 = { let mut channel_monitors = HashMap::new(); channel_monitors.insert(OutPoint { txid: chan.3.txid(), index: 0 }, &mut chan_monitor); - <(Sha256dHash, ChannelManager)>::read(&mut ::std::io::Cursor::new(previous_node_state), ChannelManagerReadArgs { - keys_manager: Arc::new(test_utils::TestKeysInterface::new(&nodes[0].node_seed, Network::Testnet, Arc::clone(&logger))), + <(Sha256dHash, ChannelManager)>::read(&mut ::std::io::Cursor::new(previous_node_state), ChannelManagerReadArgs { + keys_manager: &keys_manager, fee_estimator: feeest.clone(), monitor: &monitor, logger: Arc::clone(&logger), diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index ee706940a..8aff2fc56 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -170,7 +170,7 @@ pub type SimpleArcPeerManager = Arc = PeerManager>; +pub type SimpleRefPeerManager<'a, 'b, 'c, SD, M, T> = PeerManager>; /// A PeerManager manages a set of peers, described by their SocketDescriptor and marshalls socket /// events into messages which it passes on to its MessageHandlers. -- 2.39.5