Skip to content

Commit 6f094bb

Browse files
committed
Simplify UpdateFulfillFetch::NewClaim
The actual message is not used anywhere.
1 parent 22908ab commit 6f094bb

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ enum UpdateFulfillFetch {
10151015
NewClaim {
10161016
monitor_update: ChannelMonitorUpdate,
10171017
htlc_value_msat: u64,
1018-
msg: Option<msgs::UpdateFulfillHTLC>,
1018+
update_non_blocked: bool,
10191019
},
10201020
DuplicateClaim {},
10211021
}
@@ -5349,8 +5349,8 @@ impl<SP: Deref> FundedChannel<SP> where
53495349
let mon_update_id = self.context.latest_monitor_update_id; // Forget the ChannelMonitor update
53505350
let fulfill_resp = self.get_update_fulfill_htlc(htlc_id_arg, payment_preimage_arg, None, logger);
53515351
self.context.latest_monitor_update_id = mon_update_id;
5352-
if let UpdateFulfillFetch::NewClaim { msg, .. } = fulfill_resp {
5353-
assert!(msg.is_none()); // The HTLC must have ended up in the holding cell.
5352+
if let UpdateFulfillFetch::NewClaim { update_non_blocked, .. } = fulfill_resp {
5353+
assert!(!update_non_blocked); // The HTLC must have ended up in the holding cell.
53545354
}
53555355
}
53565356

@@ -5437,7 +5437,7 @@ impl<SP: Deref> FundedChannel<SP> where
54375437
// TODO: We may actually be able to switch to a fulfill here, though its
54385438
// rare enough it may not be worth the complexity burden.
54395439
debug_assert!(false, "Tried to fulfill an HTLC that was already failed");
5440-
return UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, msg: None };
5440+
return UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, update_non_blocked: false };
54415441
}
54425442
},
54435443
_ => {}
@@ -5447,15 +5447,15 @@ impl<SP: Deref> FundedChannel<SP> where
54475447
self.context.holding_cell_htlc_updates.push(HTLCUpdateAwaitingACK::ClaimHTLC {
54485448
payment_preimage: payment_preimage_arg, htlc_id: htlc_id_arg,
54495449
});
5450-
return UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, msg: None };
5450+
return UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, update_non_blocked: false };
54515451
}
54525452

54535453
{
54545454
let htlc = &mut self.context.pending_inbound_htlcs[pending_idx];
54555455
if let InboundHTLCState::Committed = htlc.state {
54565456
} else {
54575457
debug_assert!(false, "Have an inbound HTLC we tried to claim before it was fully committed to");
5458-
return UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, msg: None };
5458+
return UpdateFulfillFetch::NewClaim { monitor_update, htlc_value_msat, update_non_blocked: false };
54595459
}
54605460
log_trace!(logger, "Upgrading HTLC {} to LocalRemoved with a Fulfill in channel {}!", &htlc.payment_hash, &self.context.channel_id);
54615461
htlc.state = InboundHTLCState::LocalRemoved(InboundHTLCRemovalReason::Fulfill(payment_preimage_arg.clone()));
@@ -5464,11 +5464,7 @@ impl<SP: Deref> FundedChannel<SP> where
54645464
UpdateFulfillFetch::NewClaim {
54655465
monitor_update,
54665466
htlc_value_msat,
5467-
msg: Some(msgs::UpdateFulfillHTLC {
5468-
channel_id: self.context.channel_id(),
5469-
htlc_id: htlc_id_arg,
5470-
payment_preimage: payment_preimage_arg,
5471-
}),
5467+
update_non_blocked: true,
54725468
}
54735469
}
54745470

@@ -5478,13 +5474,13 @@ impl<SP: Deref> FundedChannel<SP> where
54785474
) -> UpdateFulfillCommitFetch where L::Target: Logger {
54795475
let release_cs_monitor = self.context.blocked_monitor_updates.is_empty();
54805476
match self.get_update_fulfill_htlc(htlc_id, payment_preimage, payment_info, logger) {
5481-
UpdateFulfillFetch::NewClaim { mut monitor_update, htlc_value_msat, msg } => {
5477+
UpdateFulfillFetch::NewClaim { mut monitor_update, htlc_value_msat, update_non_blocked } => {
54825478
// Even if we aren't supposed to let new monitor updates with commitment state
54835479
// updates run, we still need to push the preimage ChannelMonitorUpdateStep no
54845480
// matter what. Sadly, to push a new monitor update which flies before others
54855481
// already queued, we have to insert it into the pending queue and update the
54865482
// update_ids of all the following monitors.
5487-
if release_cs_monitor && msg.is_some() {
5483+
if release_cs_monitor && update_non_blocked {
54885484
let mut additional_update = self.build_commitment_no_status_check(logger);
54895485
// build_commitment_no_status_check may bump latest_monitor_id but we want them
54905486
// to be strictly increasing by one, so decrement it here.
@@ -5497,7 +5493,7 @@ impl<SP: Deref> FundedChannel<SP> where
54975493
for held_update in self.context.blocked_monitor_updates.iter_mut() {
54985494
held_update.update.update_id += 1;
54995495
}
5500-
if msg.is_some() {
5496+
if update_non_blocked {
55015497
debug_assert!(false, "If there is a pending blocked monitor we should have MonitorUpdateInProgress set");
55025498
let update = self.build_commitment_no_status_check(logger);
55035499
self.context.blocked_monitor_updates.push(PendingChannelMonitorUpdate {
@@ -5506,7 +5502,7 @@ impl<SP: Deref> FundedChannel<SP> where
55065502
}
55075503
}
55085504

5509-
self.monitor_updating_paused(false, msg.is_some(), false, Vec::new(), Vec::new(), Vec::new());
5505+
self.monitor_updating_paused(false, msg, false, Vec::new(), Vec::new(), Vec::new());
55105506
UpdateFulfillCommitFetch::NewClaim { monitor_update, htlc_value_msat, }
55115507
},
55125508
UpdateFulfillFetch::DuplicateClaim {} => UpdateFulfillCommitFetch::DuplicateClaim {},

0 commit comments

Comments
 (0)