Skip to content

Commit 4d51a4f

Browse files
committed
log hold times
1 parent b9cec80 commit 4d51a4f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lightning/src/ln/onion_utils.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,6 +1016,8 @@ where
10161016
const NODE: u16 = 0x2000;
10171017
const UPDATE: u16 = 0x1000;
10181018

1019+
let mut hold_times: Vec<u32> = Vec::new();
1020+
10191021
// Handle packed channel/node updates for passing back for the route handler
10201022
let callback = |shared_secret, _, _, route_hop_opt: Option<&RouteHop>, route_hop_idx| {
10211023
if res.is_some() {
@@ -1119,6 +1121,12 @@ where
11191121
return;
11201122
}
11211123

1124+
// Record hold time.
1125+
let hold_time: u32 = u32::from_be_bytes(payloads[..PAYLOAD_LEN].try_into().unwrap());
1126+
hold_times.push(hold_time);
1127+
1128+
log_debug!(logger, "Htlc hold time at pos {}: {} ms", route_hop_idx, hold_time);
1129+
11221130
// Shift payloads left.
11231131
let payloads = &mut encrypted_packet.attribution_data.as_mut().unwrap()[..MAX_HOPS * PAYLOAD_LEN]; // XXX: This will break if we get an err from an unupgraded node
11241132
payloads.copy_within(PAYLOAD_LEN.., 0);
@@ -1443,10 +1451,11 @@ impl HTLCFailReason {
14431451
pub(super) fn get_encrypted_failure_packet(
14441452
&self, incoming_packet_shared_secret: &[u8; 32], phantom_shared_secret: &Option<[u8; 32]>,
14451453
) -> msgs::OnionErrorPacket {
1446-
let payload: [u8; 4] = [1; 4];
1447-
14481454
match self.0 {
14491455
HTLCFailReasonRepr::Reason { ref failure_code, ref data } => {
1456+
let hold_time: u32 = 100;
1457+
let payload: [u8; 4] = hold_time.to_be_bytes();
1458+
14501459
if let Some(phantom_ss) = phantom_shared_secret {
14511460
let mut phantom_packet =
14521461
build_failure_packet(phantom_ss, *failure_code, &data[..], &payload);
@@ -1472,6 +1481,10 @@ impl HTLCFailReason {
14721481
HTLCFailReasonRepr::LightningError { ref err } => {
14731482
let mut err = err.clone();
14741483

1484+
// DEBUG: Use bogus hold time that differs per hop.
1485+
let hold_time: u32 = incoming_packet_shared_secret[0] as u32;
1486+
let payload: [u8; 4] = hold_time.to_be_bytes();
1487+
14751488
process_failure_packet(&mut err, incoming_packet_shared_secret, &payload);
14761489
encrypt_failure_packet(incoming_packet_shared_secret, &mut err);
14771490

0 commit comments

Comments
 (0)