Skip to content

Commit 8510d54

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 43340d6 commit 8510d54

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lightning/src/ln/channel.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7168,9 +7168,13 @@ 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_GRANULARITY_MS: u128 = 100;
7172+
7173+
let hold_time = u32::try_from(
7174+
now.saturating_sub(timestamp).as_millis()
7175+
/ HOLD_TIME_GRANULARITY_MS,
7176+
)
7177+
.unwrap_or(u32::MAX);
71747178
reason.set_hold_time(hold_time);
71757179
}
71767180

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)