Skip to content

Commit 89fa2ad

Browse files
committed
f: Simplify the is_padded test function
1 parent e8b9181 commit 89fa2ad

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

lightning/src/blinded_path/utils.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,7 @@ impl<T:Writeable> Writeable for BlindedPathWithPadding<T> {
233233
#[cfg(test)]
234234
/// Checks if all the packets in the blinded path are properly padded.
235235
pub fn is_padded(hops: &[BlindedHop], padding_round_off: usize) -> bool {
236-
let first_hop = hops.first().expect("BlindedPath must have at least one hop");
237-
let first_payload_size = first_hop.encrypted_payload.len();
238-
239-
// The unencrypted payload data is padded before getting encrypted.
240-
// Assuming the first payload is padded properly, get the extra data length.
241-
let extra_length = first_payload_size % padding_round_off;
242236
hops.iter().all(|hop| {
243-
// Check that every packet is padded to the round off length subtracting the extra length.
244-
(hop.encrypted_payload.len() - extra_length) % padding_round_off == 0
237+
hop.encrypted_payload.len() % padding_round_off == 0
245238
})
246239
}

0 commit comments

Comments
 (0)