Skip to content

Commit 345e3d1

Browse files
committed
f use existing bool rather than new argument
1 parent a2b6e15 commit 345e3d1

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4654,7 +4654,7 @@ where
46544654
for htlc in sources.drain(..) {
46554655
if let Err((pk, err)) = self.claim_funds_from_hop(
46564656
htlc.prev_hop, payment_preimage,
4657-
|_| Some(MonitorUpdateCompletionAction::PaymentClaimed { payment_hash }), false)
4657+
|_| Some(MonitorUpdateCompletionAction::PaymentClaimed { payment_hash }))
46584658
{
46594659
if let msgs::ErrorAction::IgnoreError = err.err.action {
46604660
// We got a temporary failure updating monitor, but will claim the
@@ -4684,10 +4684,15 @@ where
46844684
}
46854685

46864686
fn claim_funds_from_hop<ComplFunc: FnOnce(Option<u64>) -> Option<MonitorUpdateCompletionAction>>(&self,
4687-
prev_hop: HTLCPreviousHopData, payment_preimage: PaymentPreimage, completion_action: ComplFunc, during_init: bool)
4687+
prev_hop: HTLCPreviousHopData, payment_preimage: PaymentPreimage, completion_action: ComplFunc)
46884688
-> Result<(), (PublicKey, MsgHandleErrInternal)> {
46894689
//TODO: Delay the claimed_funds relaying just like we do outbound relay!
46904690

4691+
// If we haven't yet run background events assume we're still deserializing and shouldn't
4692+
// actually pass `ChannelMonitorUpdate`s to users yet. Instead, queue them up as
4693+
// `BackgroundEvent`s.
4694+
let during_init = !self.background_events_processed_since_startup.load(Ordering::Acquire);
4695+
46914696
{
46924697
let per_peer_state = self.per_peer_state.read().unwrap();
46934698
let chan_id = prev_hop.outpoint.to_channel_id();
@@ -4788,10 +4793,11 @@ where
47884793
self.pending_outbound_payments.finalize_claims(sources, &self.pending_events);
47894794
}
47904795

4791-
fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option<u64>, from_onchain: bool, next_channel_id: [u8; 32], during_init: bool) {
4796+
fn claim_funds_internal(&self, source: HTLCSource, payment_preimage: PaymentPreimage, forwarded_htlc_value_msat: Option<u64>, from_onchain: bool, next_channel_id: [u8; 32]) {
47924797
match source {
47934798
HTLCSource::OutboundRoute { session_priv, payment_id, path, .. } => {
4794-
debug_assert!(!during_init);
4799+
debug_assert!(self.background_events_processed_since_startup.load(Ordering::Acquire),
4800+
"We don't support claim_htlc claims during startup - monitors may not be available yet");
47954801
self.pending_outbound_payments.claim_htlc(payment_id, payment_preimage, session_priv, path, from_onchain, &self.pending_events, &self.logger);
47964802
},
47974803
HTLCSource::PreviousHopData(hop_data) => {
@@ -4814,7 +4820,7 @@ where
48144820
downstream_counterparty_and_funding_outpoint: None,
48154821
})
48164822
} else { None }
4817-
}, during_init);
4823+
});
48184824
if let Err((pk, err)) = res {
48194825
let result: Result<(), _> = Err(err);
48204826
let _ = handle_error!(self, result, pk);
@@ -5562,7 +5568,7 @@ where
55625568
hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!("Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}", counterparty_node_id), msg.channel_id))
55635569
}
55645570
};
5565-
self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(), Some(forwarded_htlc_value), false, msg.channel_id, false);
5571+
self.claim_funds_internal(htlc_source, msg.payment_preimage.clone(), Some(forwarded_htlc_value), false, msg.channel_id);
55665572
Ok(())
55675573
}
55685574

@@ -5932,7 +5938,7 @@ where
59325938
MonitorEvent::HTLCEvent(htlc_update) => {
59335939
if let Some(preimage) = htlc_update.payment_preimage {
59345940
log_trace!(self.logger, "Claiming HTLC with preimage {} from our monitor", log_bytes!(preimage.0));
5935-
self.claim_funds_internal(htlc_update.source, preimage, htlc_update.htlc_value_satoshis.map(|v| v * 1000), true, funding_outpoint.to_channel_id(), false);
5941+
self.claim_funds_internal(htlc_update.source, preimage, htlc_update.htlc_value_satoshis.map(|v| v * 1000), true, funding_outpoint.to_channel_id());
59365942
} else {
59375943
log_trace!(self.logger, "Failing HTLC with hash {} from our monitor", log_bytes!(htlc_update.payment_hash.0));
59385944
let receiver = HTLCDestination::NextHopChannel { node_id: counterparty_node_id, channel_id: funding_outpoint.to_channel_id() };
@@ -8906,7 +8912,7 @@ where
89068912
// don't remember in the `ChannelMonitor` where we got a preimage from, but if the
89078913
// channel is closed we just assume that it probably came from an on-chain claim.
89088914
channel_manager.claim_funds_internal(source, preimage, Some(downstream_value),
8909-
downstream_closed, downstream_chan_id, true);
8915+
downstream_closed, downstream_chan_id);
89108916
}
89118917

89128918
//TODO: Broadcast channel update for closed channels, but only after we've made a

0 commit comments

Comments
 (0)