Skip to content

Commit 82a7388

Browse files
committed
f style
1 parent 02249e9 commit 82a7388

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,6 @@ pub struct ChannelManager<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref,
557557
/// See `PendingOutboundPayment` documentation for more info.
558558
///
559559
/// Locked *after* channel_state.
560-
#[cfg(test)] // Exposed so that we can check there aren't dangling entries
561-
pub(crate) pending_outbound_payments: Mutex<HashMap<PaymentId, PendingOutboundPayment>>,
562-
#[cfg(not(test))]
563560
pending_outbound_payments: Mutex<HashMap<PaymentId, PendingOutboundPayment>>,
564561

565562
our_network_key: SecretKey,
@@ -1971,15 +1968,14 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
19711968
if !chan.get().is_live() {
19721969
return Err(APIError::ChannelUnavailable{err: "Peer for first hop currently disconnected/pending monitor update!".to_owned()});
19731970
}
1974-
let send_res =
1975-
break_chan_entry!(self, chan.get_mut().send_htlc_and_commit(
1976-
htlc_msat, payment_hash.clone(), htlc_cltv, HTLCSource::OutboundRoute {
1977-
path: path.clone(),
1978-
session_priv: session_priv.clone(),
1979-
first_hop_htlc_msat: htlc_msat,
1980-
payment_id,
1981-
}, onion_packet, &self.logger),
1982-
channel_state, chan);
1971+
let send_res = break_chan_entry!(self, chan.get_mut().send_htlc_and_commit(
1972+
htlc_msat, payment_hash.clone(), htlc_cltv, HTLCSource::OutboundRoute {
1973+
path: path.clone(),
1974+
session_priv: session_priv.clone(),
1975+
first_hop_htlc_msat: htlc_msat,
1976+
payment_id,
1977+
}, onion_packet, &self.logger),
1978+
channel_state, chan);
19831979

19841980
let mut pending_outbounds = self.pending_outbound_payments.lock().unwrap();
19851981
let payment = pending_outbounds.entry(payment_id).or_insert_with(|| PendingOutboundPayment::Retryable {
@@ -4392,6 +4388,11 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
43924388
self.process_pending_events(&event_handler);
43934389
events.into_inner()
43944390
}
4391+
4392+
#[cfg(test)]
4393+
pub fn has_pending_payments(&self) -> bool {
4394+
!self.pending_outbound_payments.lock().unwrap().is_empty()
4395+
}
43954396
}
43964397

43974398
impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> MessageSendEventsProvider for ChannelManager<Signer, M, T, K, F, L>

lightning/src/ln/payment_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ fn retry_expired_payment() {
227227
}
228228

229229
#[test]
230-
fn retry_on_init_fail() {
230+
fn no_pending_leak_on_initial_send_failure() {
231231
// In an earlier version of our payment tracking, we'd have a retry entry even when the initial
232-
// HTLC for payment failed to send due to local channel errors (eg peer disconnected). In this
232+
// HTLC for payment failed to send due to local channel errors (e.g. peer disconnected). In this
233233
// case, the user wouldn't have a PaymentId to retry the payment with, but we'd think we have a
234234
// pending payment forever and never time it out.
235235
// Here we test exactly that - retrying a payment when a peer was disconnected on the first
@@ -250,5 +250,5 @@ fn retry_on_init_fail() {
250250
true, APIError::ChannelUnavailable { ref err },
251251
assert_eq!(err, "Peer for first hop currently disconnected/pending monitor update!"));
252252

253-
assert!(nodes[0].node.pending_outbound_payments.lock().unwrap().is_empty());
253+
assert!(!nodes[0].node.has_pending_payments());
254254
}

0 commit comments

Comments
 (0)