Skip to content

Commit 74c5e03

Browse files
f Antoine feedback: rename pending_forward_state and remove comment
1 parent a8e5da0 commit 74c5e03

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

lightning/src/ln/channel.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,17 +1733,12 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
17331733
self.commit_tx_fee_msat(their_acked_htlcs + addl_htlcs)
17341734
}
17351735

1736-
pub fn update_add_htlc<F>(&mut self, msg: &msgs::UpdateAddHTLC, mut pending_forward_state: PendingHTLCStatus, create_pending_htlc_status: F) -> Result<(), ChannelError>
1736+
pub fn update_add_htlc<F>(&mut self, msg: &msgs::UpdateAddHTLC, mut pending_forward_status: PendingHTLCStatus, create_pending_htlc_status: F) -> Result<(), ChannelError>
17371737
where F: for<'a> Fn(&'a Self, PendingHTLCStatus, u16) -> PendingHTLCStatus {
17381738
// We can't accept HTLCs sent after we've sent a shutdown.
17391739
let local_sent_shutdown = (self.channel_state & (ChannelState::ChannelFunded as u32 | ChannelState::LocalShutdownSent as u32)) != (ChannelState::ChannelFunded as u32);
17401740
if local_sent_shutdown {
1741-
// TODO: Note that |20 is defined as "channel FROM the processing
1742-
// node has been disabled" (emphasis mine), which seems to imply
1743-
// that we can't return |20 for an inbound channel being disabled.
1744-
// This probably needs a spec update but should definitely be
1745-
// allowed.
1746-
pending_forward_state = create_pending_htlc_status(self, pending_forward_state, 0x1000|20);
1741+
pending_forward_status = create_pending_htlc_status(self, pending_forward_status, 0x1000|20);
17471742
}
17481743
// If the remote has sent a shutdown prior to adding this HTLC, then they are in violation of the spec.
17491744
let remote_sent_shutdown = (self.channel_state & (ChannelState::ChannelFunded as u32 | ChannelState::RemoteShutdownSent as u32)) != (ChannelState::ChannelFunded as u32);
@@ -1823,9 +1818,9 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
18231818
// being sensitive to fee spikes.
18241819
let remote_fee_cost_incl_stuck_buffer_msat = 2 * self.next_remote_commit_tx_fee_msat(1 + 1);
18251820
if pending_remote_value_msat - msg.amount_msat - chan_reserve_msat < remote_fee_cost_incl_stuck_buffer_msat {
1826-
// Note that if the pending_forward_state is not updated here, then it's because we're already failing
1821+
// Note that if the pending_forward_status is not updated here, then it's because we're already failing
18271822
// the HTLC, i.e. its status is already set to failing.
1828-
pending_forward_state = create_pending_htlc_status(self, pending_forward_state, 0x1000|7);
1823+
pending_forward_status = create_pending_htlc_status(self, pending_forward_status, 0x1000|7);
18291824
}
18301825
} else {
18311826
// Check that they won't violate our local required channel reserve by adding this HTLC.
@@ -1845,7 +1840,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
18451840
}
18461841

18471842
if self.channel_state & ChannelState::LocalShutdownSent as u32 != 0 {
1848-
if let PendingHTLCStatus::Forward(_) = pending_forward_state {
1843+
if let PendingHTLCStatus::Forward(_) = pending_forward_status {
18491844
panic!("ChannelManager shouldn't be trying to add a forwardable HTLC after we've started closing");
18501845
}
18511846
}
@@ -1857,7 +1852,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
18571852
amount_msat: msg.amount_msat,
18581853
payment_hash: msg.payment_hash,
18591854
cltv_expiry: msg.cltv_expiry,
1860-
state: InboundHTLCState::RemoteAnnounced(pending_forward_state),
1855+
state: InboundHTLCState::RemoteAnnounced(pending_forward_status),
18611856
});
18621857
Ok(())
18631858
}

0 commit comments

Comments
 (0)