From d6382f5ed455e73784d26ee02f7365dd3edf85e0 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 20 Dec 2019 14:53:16 -0500 Subject: [PATCH] Remove unused lifetimes. f71518365f61a5fe2a0340953ad6592c0d2b72cc added a series of lifetimes which were required for an earlier version of the patch but not the final version. They can be freely removed. --- fuzz/src/full_stack.rs | 10 ++++----- lightning/src/chain/chaininterface.rs | 10 ++++----- lightning/src/ln/channelmanager.rs | 26 +++++++++++------------ lightning/src/ln/functional_test_utils.rs | 18 ++++++++-------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/fuzz/src/full_stack.rs b/fuzz/src/full_stack.rs index fc8232f29..6ed7263a7 100644 --- a/fuzz/src/full_stack.rs +++ b/fuzz/src/full_stack.rs @@ -135,8 +135,8 @@ impl<'a> Hash for Peer<'a> { } } -struct MoneyLossDetector<'a, 'b> { - manager: Arc>, +struct MoneyLossDetector<'a> { + manager: Arc>, monitor: Arc>, handler: PeerManager>, @@ -148,8 +148,8 @@ struct MoneyLossDetector<'a, 'b> { max_height: usize, blocks_connected: u32, } -impl<'a, 'b> MoneyLossDetector<'a, 'b> { - pub fn new(peers: &'a RefCell<[bool; 256]>, manager: Arc>, monitor: Arc>, handler: PeerManager>) -> Self { +impl<'a> MoneyLossDetector<'a> { + pub fn new(peers: &'a RefCell<[bool; 256]>, manager: Arc>, monitor: Arc>, handler: PeerManager>) -> Self { MoneyLossDetector { manager, monitor, @@ -208,7 +208,7 @@ impl<'a, 'b> MoneyLossDetector<'a, 'b> { } } -impl<'a, 'b> Drop for MoneyLossDetector<'a, 'b> { +impl<'a> Drop for MoneyLossDetector<'a> { fn drop(&mut self) { if !::std::thread::panicking() { // Disconnect all peers diff --git a/lightning/src/chain/chaininterface.rs b/lightning/src/chain/chaininterface.rs index ac7ba05a0..4f5eeeac5 100644 --- a/lightning/src/chain/chaininterface.rs +++ b/lightning/src/chain/chaininterface.rs @@ -207,14 +207,14 @@ impl ChainWatchedUtil { /// Utility for notifying listeners about new blocks, and handling block rescans if new watch /// data is registered. -pub struct BlockNotifier<'a> { - listeners: Mutex>>, //TODO(vmw): try removing Weak +pub struct BlockNotifier { + listeners: Mutex>>, //TODO(vmw): try removing Weak chain_monitor: Arc, } -impl<'a> BlockNotifier<'a> { +impl BlockNotifier { /// Constructs a new BlockNotifier without any listeners. - pub fn new(chain_monitor: Arc) -> BlockNotifier<'a> { + pub fn new(chain_monitor: Arc) -> BlockNotifier { BlockNotifier { listeners: Mutex::new(Vec::new()), chain_monitor, @@ -224,7 +224,7 @@ impl<'a> BlockNotifier<'a> { /// Register the given listener to receive events. Only a weak pointer is provided and /// the registration should be freed once that pointer expires. // TODO: unregister - pub fn register_listener(&self, listener: Weak) { + pub fn register_listener(&self, listener: Weak) { let mut vec = self.listeners.lock().unwrap(); vec.push(listener); } diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 8ff6918d4..2773c1758 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -326,11 +326,11 @@ const ERR: () = "You need at least 32 bit pointers (well, usize, but we'll assum /// spam due to quick disconnection/reconnection, updates are not sent until the channel has been /// offline for a full minute. In order to track this, you must call /// timer_chan_freshness_every_min roughly once per minute, though it doesn't have to be perfec. -pub struct ChannelManager<'a, ChanSigner: ChannelKeys> { +pub struct ChannelManager { default_configuration: UserConfig, genesis_hash: Sha256dHash, fee_estimator: Arc, - monitor: Arc, + monitor: Arc, tx_broadcaster: Arc, #[cfg(test)] @@ -583,7 +583,7 @@ macro_rules! maybe_break_monitor_err { } } -impl<'a, ChanSigner: ChannelKeys> ChannelManager<'a, ChanSigner> { +impl ChannelManager { /// Constructs a new ChannelManager to hold several channels and route between them. /// /// This is the main "logic hub" for all channel-related actions, and implements @@ -602,7 +602,7 @@ impl<'a, ChanSigner: ChannelKeys> ChannelManager<'a, ChanSigner> { /// the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's /// `block_(dis)connected` methods, which will notify all registered listeners in one /// go. - pub fn new(network: Network, feeest: Arc, monitor: Arc, tx_broadcaster: Arc, logger: Arc,keys_manager: Arc>, config: UserConfig, current_blockchain_height: usize) -> Result>, secp256k1::Error> { + pub fn new(network: Network, feeest: Arc, monitor: Arc, tx_broadcaster: Arc, logger: Arc,keys_manager: Arc>, config: UserConfig, current_blockchain_height: usize) -> Result>, secp256k1::Error> { let secp_ctx = Secp256k1::new(); let res = Arc::new(ChannelManager { @@ -2567,7 +2567,7 @@ impl<'a, ChanSigner: ChannelKeys> ChannelManager<'a, ChanSigner> { } } -impl<'a, ChanSigner: ChannelKeys> events::MessageSendEventsProvider for ChannelManager<'a, ChanSigner> { +impl events::MessageSendEventsProvider for ChannelManager { 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 // user to serialize a ChannelManager with pending events in it and lose those events on @@ -2592,7 +2592,7 @@ impl<'a, ChanSigner: ChannelKeys> events::MessageSendEventsProvider for ChannelM } } -impl<'a, ChanSigner: ChannelKeys> events::EventsProvider for ChannelManager<'a, ChanSigner> { +impl events::EventsProvider for ChannelManager { 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 // user to serialize a ChannelManager with pending events in it and lose those events on @@ -2617,7 +2617,7 @@ impl<'a, ChanSigner: ChannelKeys> events::EventsProvider for ChannelManager<'a, } } -impl<'a, ChanSigner: ChannelKeys> ChainListener for ChannelManager<'a, ChanSigner> { +impl ChainListener for ChannelManager { fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]) { let header_hash = header.bitcoin_hash(); log_trace!(self, "Block {} at height {} connected with {} txn matched", header_hash, height, txn_matched.len()); @@ -2731,7 +2731,7 @@ impl<'a, ChanSigner: ChannelKeys> ChainListener for ChannelManager<'a, ChanSigne } } -impl<'a, ChanSigner: ChannelKeys> ChannelMessageHandler for ChannelManager<'a, ChanSigner> { +impl ChannelMessageHandler for ChannelManager { //TODO: Handle errors and close channel (or so) fn handle_open_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &msgs::OpenChannel) -> Result<(), LightningError> { let _ = self.total_consistency_lock.read().unwrap(); @@ -3116,7 +3116,7 @@ impl Readable for HTLCForwardInfo { } } -impl<'a, ChanSigner: ChannelKeys + Writeable> Writeable for ChannelManager<'a, ChanSigner> { +impl Writeable for ChannelManager { fn write(&self, writer: &mut W) -> Result<(), ::std::io::Error> { let _ = self.total_consistency_lock.write().unwrap(); @@ -3179,7 +3179,7 @@ impl<'a, ChanSigner: ChannelKeys + Writeable> Writeable for ChannelManager<'a, C /// 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, 'b, ChanSigner: ChannelKeys> { +pub struct ChannelManagerReadArgs<'a, ChanSigner: ChannelKeys> { /// The keys provider which will give us relevant keys. Some keys will be loaded during /// deserialization. pub keys_manager: Arc>, @@ -3193,7 +3193,7 @@ pub struct ChannelManagerReadArgs<'a, 'b, ChanSigner: ChannelKeys> { /// No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that /// you have deserialized ChannelMonitors separately and will add them to your /// ManyChannelMonitor after deserializing this ChannelManager. - pub monitor: Arc, + pub monitor: Arc, /// The BroadcasterInterface which will be used in the ChannelManager in the future and may be /// used to broadcast the latest local commitment transactions of channels which must be @@ -3219,8 +3219,8 @@ pub struct ChannelManagerReadArgs<'a, 'b, ChanSigner: ChannelKeys> { pub channel_monitors: &'a HashMap, } -impl<'a, 'b, R : ::std::io::Read, ChanSigner: ChannelKeys + Readable> ReadableArgs> for (Sha256dHash, ChannelManager<'b, ChanSigner>) { - fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, 'b, ChanSigner>) -> Result { +impl<'a, R : ::std::io::Read, ChanSigner: ChannelKeys + Readable> ReadableArgs> for (Sha256dHash, ChannelManager) { + fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, ChanSigner>) -> 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 108bbc137..45e04b946 100644 --- a/lightning/src/ln/functional_test_utils.rs +++ b/lightning/src/ln/functional_test_utils.rs @@ -55,19 +55,19 @@ pub fn connect_blocks(notifier: &chaininterface::BlockNotifier, depth: u32, heig header.bitcoin_hash() } -pub struct Node<'a, 'b: 'a> { - pub block_notifier: Arc>, +pub struct Node { + pub block_notifier: Arc, pub chain_monitor: Arc, pub tx_broadcaster: Arc, pub chan_monitor: Arc, pub keys_manager: Arc, - pub node: Arc>, + pub node: Arc>, pub router: Router, pub node_seed: [u8; 32], pub network_payment_count: Rc>, pub network_chan_count: Rc>, } -impl<'a, 'b> Drop for Node<'a, 'b> { +impl Drop for Node { fn drop(&mut self) { if !::std::thread::panicking() { // Check that we processed all pending events @@ -355,7 +355,7 @@ macro_rules! check_closed_broadcast { }} } -pub fn close_channel<'a, 'b>(outbound_node: &Node<'a, 'b>, inbound_node: &Node<'a, 'b>, channel_id: &[u8; 32], funding_tx: Transaction, close_inbound_first: bool) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, Transaction) { +pub fn close_channel(outbound_node: &Node, inbound_node: &Node, channel_id: &[u8; 32], funding_tx: Transaction, close_inbound_first: bool) -> (msgs::ChannelUpdate, msgs::ChannelUpdate, Transaction) { let (node_a, broadcaster_a, struct_a) = if close_inbound_first { (&inbound_node.node, &inbound_node.tx_broadcaster, inbound_node) } else { (&outbound_node.node, &outbound_node.tx_broadcaster, outbound_node) }; let (node_b, broadcaster_b) = if close_inbound_first { (&outbound_node.node, &outbound_node.tx_broadcaster) } else { (&inbound_node.node, &inbound_node.tx_broadcaster) }; let (tx_a, tx_b); @@ -590,7 +590,7 @@ macro_rules! expect_payment_sent { } } -pub fn send_along_route_with_hash<'a, 'b>(origin_node: &Node<'a, 'b>, route: Route, expected_route: &[&Node<'a, 'b>], recv_value: u64, our_payment_hash: PaymentHash) { +pub fn send_along_route_with_hash(origin_node: &Node, route: Route, expected_route: &[&Node], recv_value: u64, our_payment_hash: PaymentHash) { let mut payment_event = { origin_node.node.send_payment(route, our_payment_hash).unwrap(); check_added_monitors!(origin_node, 1); @@ -632,7 +632,7 @@ pub fn send_along_route_with_hash<'a, 'b>(origin_node: &Node<'a, 'b>, route: Rou } } -pub fn send_along_route<'a, 'b>(origin_node: &Node<'a, 'b>, route: Route, expected_route: &[&Node<'a, 'b>], recv_value: u64) -> (PaymentPreimage, PaymentHash) { +pub fn send_along_route(origin_node: &Node, route: Route, expected_route: &[&Node], recv_value: u64) -> (PaymentPreimage, PaymentHash) { let (our_payment_preimage, our_payment_hash) = get_payment_preimage_hash!(origin_node); send_along_route_with_hash(origin_node, route, expected_route, recv_value, our_payment_hash); (our_payment_preimage, our_payment_hash) @@ -722,7 +722,7 @@ pub fn claim_payment(origin_node: &Node, expected_route: &[&Node], our_payment_p pub const TEST_FINAL_CLTV: u32 = 32; -pub fn route_payment<'a, 'b>(origin_node: &Node<'a, 'b>, expected_route: &[&Node<'a, 'b>], recv_value: u64) -> (PaymentPreimage, PaymentHash) { +pub fn route_payment(origin_node: &Node, expected_route: &[&Node], recv_value: u64) -> (PaymentPreimage, PaymentHash) { let route = origin_node.router.get_route(&expected_route.last().unwrap().node.get_our_node_id(), None, &Vec::new(), recv_value, TEST_FINAL_CLTV).unwrap(); assert_eq!(route.hops.len(), expected_route.len()); for (node, hop) in expected_route.iter().zip(route.hops.iter()) { @@ -748,7 +748,7 @@ pub fn route_over_limit(origin_node: &Node, expected_route: &[&Node], recv_value }; } -pub fn send_payment<'a, 'b>(origin: &Node<'a, 'b>, expected_route: &[&Node<'a, 'b>], recv_value: u64, expected_value: u64) { +pub fn send_payment(origin: &Node, expected_route: &[&Node], recv_value: u64, expected_value: u64) { let our_payment_preimage = route_payment(&origin, expected_route, recv_value).0; claim_payment(&origin, expected_route, our_payment_preimage, expected_value); } -- 2.39.5