Skip to content

Commit f755ae5

Browse files
authored
Merge pull request #426 from TheBlueMatt/2019-12-bad-lifetimes
Remove unused lifetimes.
2 parents 3b76c77 + d6382f5 commit f755ae5

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

fuzz/src/full_stack.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ impl<'a> Hash for Peer<'a> {
135135
}
136136
}
137137

138-
struct MoneyLossDetector<'a, 'b> {
139-
manager: Arc<ChannelManager<'b, EnforcingChannelKeys>>,
138+
struct MoneyLossDetector<'a> {
139+
manager: Arc<ChannelManager<EnforcingChannelKeys>>,
140140
monitor: Arc<channelmonitor::SimpleManyChannelMonitor<OutPoint>>,
141141
handler: PeerManager<Peer<'a>>,
142142

@@ -148,8 +148,8 @@ struct MoneyLossDetector<'a, 'b> {
148148
max_height: usize,
149149
blocks_connected: u32,
150150
}
151-
impl<'a, 'b> MoneyLossDetector<'a, 'b> {
152-
pub fn new(peers: &'a RefCell<[bool; 256]>, manager: Arc<ChannelManager<'b, EnforcingChannelKeys>>, monitor: Arc<channelmonitor::SimpleManyChannelMonitor<OutPoint>>, handler: PeerManager<Peer<'a>>) -> Self {
151+
impl<'a> MoneyLossDetector<'a> {
152+
pub fn new(peers: &'a RefCell<[bool; 256]>, manager: Arc<ChannelManager<EnforcingChannelKeys>>, monitor: Arc<channelmonitor::SimpleManyChannelMonitor<OutPoint>>, handler: PeerManager<Peer<'a>>) -> Self {
153153
MoneyLossDetector {
154154
manager,
155155
monitor,
@@ -208,7 +208,7 @@ impl<'a, 'b> MoneyLossDetector<'a, 'b> {
208208
}
209209
}
210210

211-
impl<'a, 'b> Drop for MoneyLossDetector<'a, 'b> {
211+
impl<'a> Drop for MoneyLossDetector<'a> {
212212
fn drop(&mut self) {
213213
if !::std::thread::panicking() {
214214
// Disconnect all peers

lightning/src/chain/chaininterface.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,14 @@ impl ChainWatchedUtil {
207207

208208
/// Utility for notifying listeners about new blocks, and handling block rescans if new watch
209209
/// data is registered.
210-
pub struct BlockNotifier<'a> {
211-
listeners: Mutex<Vec<Weak<ChainListener + 'a>>>, //TODO(vmw): try removing Weak
210+
pub struct BlockNotifier {
211+
listeners: Mutex<Vec<Weak<ChainListener>>>, //TODO(vmw): try removing Weak
212212
chain_monitor: Arc<ChainWatchInterface>,
213213
}
214214

215-
impl<'a> BlockNotifier<'a> {
215+
impl BlockNotifier {
216216
/// Constructs a new BlockNotifier without any listeners.
217-
pub fn new(chain_monitor: Arc<ChainWatchInterface>) -> BlockNotifier<'a> {
217+
pub fn new(chain_monitor: Arc<ChainWatchInterface>) -> BlockNotifier {
218218
BlockNotifier {
219219
listeners: Mutex::new(Vec::new()),
220220
chain_monitor,
@@ -224,7 +224,7 @@ impl<'a> BlockNotifier<'a> {
224224
/// Register the given listener to receive events. Only a weak pointer is provided and
225225
/// the registration should be freed once that pointer expires.
226226
// TODO: unregister
227-
pub fn register_listener(&self, listener: Weak<ChainListener + 'a>) {
227+
pub fn register_listener(&self, listener: Weak<ChainListener>) {
228228
let mut vec = self.listeners.lock().unwrap();
229229
vec.push(listener);
230230
}

lightning/src/ln/channelmanager.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ const ERR: () = "You need at least 32 bit pointers (well, usize, but we'll assum
326326
/// spam due to quick disconnection/reconnection, updates are not sent until the channel has been
327327
/// offline for a full minute. In order to track this, you must call
328328
/// timer_chan_freshness_every_min roughly once per minute, though it doesn't have to be perfec.
329-
pub struct ChannelManager<'a, ChanSigner: ChannelKeys> {
329+
pub struct ChannelManager<ChanSigner: ChannelKeys> {
330330
default_configuration: UserConfig,
331331
genesis_hash: Sha256dHash,
332332
fee_estimator: Arc<FeeEstimator>,
333-
monitor: Arc<ManyChannelMonitor + 'a>,
333+
monitor: Arc<ManyChannelMonitor>,
334334
tx_broadcaster: Arc<BroadcasterInterface>,
335335

336336
#[cfg(test)]
@@ -583,7 +583,7 @@ macro_rules! maybe_break_monitor_err {
583583
}
584584
}
585585

586-
impl<'a, ChanSigner: ChannelKeys> ChannelManager<'a, ChanSigner> {
586+
impl<ChanSigner: ChannelKeys> ChannelManager<ChanSigner> {
587587
/// Constructs a new ChannelManager to hold several channels and route between them.
588588
///
589589
/// This is the main "logic hub" for all channel-related actions, and implements
@@ -602,7 +602,7 @@ impl<'a, ChanSigner: ChannelKeys> ChannelManager<'a, ChanSigner> {
602602
/// the ChannelManager as a listener to the BlockNotifier and call the BlockNotifier's
603603
/// `block_(dis)connected` methods, which will notify all registered listeners in one
604604
/// go.
605-
pub fn new(network: Network, feeest: Arc<FeeEstimator>, monitor: Arc<ManyChannelMonitor + 'a>, tx_broadcaster: Arc<BroadcasterInterface>, logger: Arc<Logger>,keys_manager: Arc<KeysInterface<ChanKeySigner = ChanSigner>>, config: UserConfig, current_blockchain_height: usize) -> Result<Arc<ChannelManager<'a, ChanSigner>>, secp256k1::Error> {
605+
pub fn new(network: Network, feeest: Arc<FeeEstimator>, monitor: Arc<ManyChannelMonitor>, tx_broadcaster: Arc<BroadcasterInterface>, logger: Arc<Logger>,keys_manager: Arc<KeysInterface<ChanKeySigner = ChanSigner>>, config: UserConfig, current_blockchain_height: usize) -> Result<Arc<ChannelManager<ChanSigner>>, secp256k1::Error> {
606606
let secp_ctx = Secp256k1::new();
607607

608608
let res = Arc::new(ChannelManager {
@@ -2567,7 +2567,7 @@ impl<'a, ChanSigner: ChannelKeys> ChannelManager<'a, ChanSigner> {
25672567
}
25682568
}
25692569

2570-
impl<'a, ChanSigner: ChannelKeys> events::MessageSendEventsProvider for ChannelManager<'a, ChanSigner> {
2570+
impl<ChanSigner: ChannelKeys> events::MessageSendEventsProvider for ChannelManager<ChanSigner> {
25712571
fn get_and_clear_pending_msg_events(&self) -> Vec<events::MessageSendEvent> {
25722572
// TODO: Event release to users and serialization is currently race-y: it's very easy for a
25732573
// 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
25922592
}
25932593
}
25942594

2595-
impl<'a, ChanSigner: ChannelKeys> events::EventsProvider for ChannelManager<'a, ChanSigner> {
2595+
impl<ChanSigner: ChannelKeys> events::EventsProvider for ChannelManager<ChanSigner> {
25962596
fn get_and_clear_pending_events(&self) -> Vec<events::Event> {
25972597
// TODO: Event release to users and serialization is currently race-y: it's very easy for a
25982598
// 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,
26172617
}
26182618
}
26192619

2620-
impl<'a, ChanSigner: ChannelKeys> ChainListener for ChannelManager<'a, ChanSigner> {
2620+
impl<ChanSigner: ChannelKeys> ChainListener for ChannelManager<ChanSigner> {
26212621
fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], indexes_of_txn_matched: &[u32]) {
26222622
let header_hash = header.bitcoin_hash();
26232623
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
27312731
}
27322732
}
27332733

2734-
impl<'a, ChanSigner: ChannelKeys> ChannelMessageHandler for ChannelManager<'a, ChanSigner> {
2734+
impl<ChanSigner: ChannelKeys> ChannelMessageHandler for ChannelManager<ChanSigner> {
27352735
//TODO: Handle errors and close channel (or so)
27362736
fn handle_open_channel(&self, their_node_id: &PublicKey, their_local_features: LocalFeatures, msg: &msgs::OpenChannel) -> Result<(), LightningError> {
27372737
let _ = self.total_consistency_lock.read().unwrap();
@@ -3116,7 +3116,7 @@ impl<R: ::std::io::Read> Readable<R> for HTLCForwardInfo {
31163116
}
31173117
}
31183118

3119-
impl<'a, ChanSigner: ChannelKeys + Writeable> Writeable for ChannelManager<'a, ChanSigner> {
3119+
impl<ChanSigner: ChannelKeys + Writeable> Writeable for ChannelManager<ChanSigner> {
31203120
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), ::std::io::Error> {
31213121
let _ = self.total_consistency_lock.write().unwrap();
31223122

@@ -3179,7 +3179,7 @@ impl<'a, ChanSigner: ChannelKeys + Writeable> Writeable for ChannelManager<'a, C
31793179
/// 5) Move the ChannelMonitors into your local ManyChannelMonitor.
31803180
/// 6) Disconnect/connect blocks on the ChannelManager.
31813181
/// 7) Register the new ChannelManager with your ChainWatchInterface.
3182-
pub struct ChannelManagerReadArgs<'a, 'b, ChanSigner: ChannelKeys> {
3182+
pub struct ChannelManagerReadArgs<'a, ChanSigner: ChannelKeys> {
31833183
/// The keys provider which will give us relevant keys. Some keys will be loaded during
31843184
/// deserialization.
31853185
pub keys_manager: Arc<KeysInterface<ChanKeySigner = ChanSigner>>,
@@ -3193,7 +3193,7 @@ pub struct ChannelManagerReadArgs<'a, 'b, ChanSigner: ChannelKeys> {
31933193
/// No calls to the ManyChannelMonitor will be made during deserialization. It is assumed that
31943194
/// you have deserialized ChannelMonitors separately and will add them to your
31953195
/// ManyChannelMonitor after deserializing this ChannelManager.
3196-
pub monitor: Arc<ManyChannelMonitor + 'b>,
3196+
pub monitor: Arc<ManyChannelMonitor>,
31973197

31983198
/// The BroadcasterInterface which will be used in the ChannelManager in the future and may be
31993199
/// used to broadcast the latest local commitment transactions of channels which must be
@@ -3219,8 +3219,8 @@ pub struct ChannelManagerReadArgs<'a, 'b, ChanSigner: ChannelKeys> {
32193219
pub channel_monitors: &'a HashMap<OutPoint, &'a ChannelMonitor>,
32203220
}
32213221

3222-
impl<'a, 'b, R : ::std::io::Read, ChanSigner: ChannelKeys + Readable<R>> ReadableArgs<R, ChannelManagerReadArgs<'a, 'b, ChanSigner>> for (Sha256dHash, ChannelManager<'b, ChanSigner>) {
3223-
fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, 'b, ChanSigner>) -> Result<Self, DecodeError> {
3222+
impl<'a, R : ::std::io::Read, ChanSigner: ChannelKeys + Readable<R>> ReadableArgs<R, ChannelManagerReadArgs<'a, ChanSigner>> for (Sha256dHash, ChannelManager<ChanSigner>) {
3223+
fn read(reader: &mut R, args: ChannelManagerReadArgs<'a, ChanSigner>) -> Result<Self, DecodeError> {
32243224
let _ver: u8 = Readable::read(reader)?;
32253225
let min_ver: u8 = Readable::read(reader)?;
32263226
if min_ver > SERIALIZATION_VERSION {

lightning/src/ln/functional_test_utils.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,19 @@ pub fn connect_blocks(notifier: &chaininterface::BlockNotifier, depth: u32, heig
5555
header.bitcoin_hash()
5656
}
5757

58-
pub struct Node<'a, 'b: 'a> {
59-
pub block_notifier: Arc<chaininterface::BlockNotifier<'a>>,
58+
pub struct Node {
59+
pub block_notifier: Arc<chaininterface::BlockNotifier>,
6060
pub chain_monitor: Arc<chaininterface::ChainWatchInterfaceUtil>,
6161
pub tx_broadcaster: Arc<test_utils::TestBroadcaster>,
6262
pub chan_monitor: Arc<test_utils::TestChannelMonitor>,
6363
pub keys_manager: Arc<test_utils::TestKeysInterface>,
64-
pub node: Arc<ChannelManager<'b, EnforcingChannelKeys>>,
64+
pub node: Arc<ChannelManager<EnforcingChannelKeys>>,
6565
pub router: Router,
6666
pub node_seed: [u8; 32],
6767
pub network_payment_count: Rc<RefCell<u8>>,
6868
pub network_chan_count: Rc<RefCell<u32>>,
6969
}
70-
impl<'a, 'b> Drop for Node<'a, 'b> {
70+
impl Drop for Node {
7171
fn drop(&mut self) {
7272
if !::std::thread::panicking() {
7373
// Check that we processed all pending events
@@ -355,7 +355,7 @@ macro_rules! check_closed_broadcast {
355355
}}
356356
}
357357

358-
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) {
358+
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) {
359359
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) };
360360
let (node_b, broadcaster_b) = if close_inbound_first { (&outbound_node.node, &outbound_node.tx_broadcaster) } else { (&inbound_node.node, &inbound_node.tx_broadcaster) };
361361
let (tx_a, tx_b);
@@ -590,7 +590,7 @@ macro_rules! expect_payment_sent {
590590
}
591591
}
592592

593-
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) {
593+
pub fn send_along_route_with_hash(origin_node: &Node, route: Route, expected_route: &[&Node], recv_value: u64, our_payment_hash: PaymentHash) {
594594
let mut payment_event = {
595595
origin_node.node.send_payment(route, our_payment_hash).unwrap();
596596
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
632632
}
633633
}
634634

635-
pub fn send_along_route<'a, 'b>(origin_node: &Node<'a, 'b>, route: Route, expected_route: &[&Node<'a, 'b>], recv_value: u64) -> (PaymentPreimage, PaymentHash) {
635+
pub fn send_along_route(origin_node: &Node, route: Route, expected_route: &[&Node], recv_value: u64) -> (PaymentPreimage, PaymentHash) {
636636
let (our_payment_preimage, our_payment_hash) = get_payment_preimage_hash!(origin_node);
637637
send_along_route_with_hash(origin_node, route, expected_route, recv_value, our_payment_hash);
638638
(our_payment_preimage, our_payment_hash)
@@ -722,7 +722,7 @@ pub fn claim_payment(origin_node: &Node, expected_route: &[&Node], our_payment_p
722722

723723
pub const TEST_FINAL_CLTV: u32 = 32;
724724

725-
pub fn route_payment<'a, 'b>(origin_node: &Node<'a, 'b>, expected_route: &[&Node<'a, 'b>], recv_value: u64) -> (PaymentPreimage, PaymentHash) {
725+
pub fn route_payment(origin_node: &Node, expected_route: &[&Node], recv_value: u64) -> (PaymentPreimage, PaymentHash) {
726726
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();
727727
assert_eq!(route.hops.len(), expected_route.len());
728728
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
748748
};
749749
}
750750

751-
pub fn send_payment<'a, 'b>(origin: &Node<'a, 'b>, expected_route: &[&Node<'a, 'b>], recv_value: u64, expected_value: u64) {
751+
pub fn send_payment(origin: &Node, expected_route: &[&Node], recv_value: u64, expected_value: u64) {
752752
let our_payment_preimage = route_payment(&origin, expected_route, recv_value).0;
753753
claim_payment(&origin, expected_route, our_payment_preimage, expected_value);
754754
}

0 commit comments

Comments
 (0)