Skip to content

Commit 091d3f9

Browse files
committed
f - replace new timeout buffer with existing grace period
1 parent ee5f741 commit 091d3f9

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,6 @@ pub const ANTI_REORG_DELAY: u32 = 6;
243243
/// in a race condition between the user connecting a block (which would fail it) and the user
244244
/// providing us the preimage (which would claim it).
245245
pub(crate) const HTLC_FAIL_BACK_BUFFER: u32 = CLTV_CLAIM_BUFFER + LATENCY_GRACE_PERIOD_BLOCKS;
246-
/// Number of blocks before an inbound HTLC expires at which we fail it backwards.
247-
///
248-
/// If we have forwarded an HTLC to a peer and they have not claimed it on or off-chain by the
249-
/// time the previous hop's HTLC timeout expires, we're probably going to lose the inbound HTLC.
250-
/// Instead of also losing the channel, we fail the HTLC backwards.
251-
///
252-
/// To give us some buffer in case we're slow to process blocks, we fail a few blocks before the
253-
/// timeout officially expires to ensure we fail back before our counterparty force closes.
254-
pub(crate) const TIMEOUT_FAIL_BACK_BUFFER: u32 = 3;
255246

256247
// TODO(devrandom) replace this with HolderCommitmentTransaction
257248
#[derive(Clone, PartialEq, Eq)]
@@ -3531,7 +3522,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35313522
}
35323523
}
35333524

3534-
// Fail back HTLCs on backwards channels if they expire within `TIMEOUT_FAIL_BACK_BUFFER`
3525+
// Fail back HTLCs on backwards channels if they expire within `LATENCY_GRACE_PERIOD_BLOCKS`
35353526
// blocks. If we haven't seen the preimage for an HTLC by the time the previous hop's
35363527
// timeout expires, we've lost that HTLC, so we might as well fail it back instead of having our
35373528
// counterparty force-close the channel.
@@ -3548,7 +3539,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35483539
HTLCSource::PreviousHopData(HTLCPreviousHopData { htlc_id, cltv_expiry: Some(cltv_expiry), .. }) if !self.failed_back_htlc_ids.contains(htlc_id) => (*cltv_expiry, *htlc_id),
35493540
_ => continue,
35503541
};
3551-
if cltv_expiry <= height + TIMEOUT_FAIL_BACK_BUFFER {
3542+
if cltv_expiry <= height + LATENCY_GRACE_PERIOD_BLOCKS {
35523543
let duplicate_event = self.pending_monitor_events.iter().any(
35533544
|update| if let &MonitorEvent::HTLCEvent(ref upd) = update {
35543545
upd.source == *source

0 commit comments

Comments
 (0)