Skip to content

Commit 1bcf587

Browse files
committed
Reduce hold time resolution
In the spec process, it was agreed to report hold time in multiples of 100 ms.
1 parent 7b80d09 commit 1bcf587

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7168,9 +7168,11 @@ where
71687168
if let OutboundHTLCOutcome::Failure(mut reason) = outcome.clone() {
71697169
// We really want take() here, but, again, non-mut ref :(
71707170
if let (Some(timestamp), Some(now)) = (htlc.send_timestamp, now) {
7171-
let hold_time =
7172-
u32::try_from(now.saturating_sub(timestamp).as_millis())
7173-
.unwrap_or(u32::MAX);
7171+
const HOLD_TIME_UNIT_MILLIS: u128 = 100;
7172+
7173+
let elapsed_millis = now.saturating_sub(timestamp).as_millis();
7174+
let elapsed_units = elapsed_millis / HOLD_TIME_UNIT_MILLIS;
7175+
let hold_time = u32::try_from(elapsed_units).unwrap_or(u32::MAX);
71747176
reason.set_hold_time(hold_time);
71757177
}
71767178

lightning/src/ln/onion_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ where
12231223
logger,
12241224
"Htlc hold time at pos {}: {} ms",
12251225
route_hop_idx,
1226-
hold_time
1226+
hold_time * 100
12271227
);
12281228

12291229
// Shift attribution data to prepare for processing the next hop.

0 commit comments

Comments
 (0)