Not including gateway non-delay when calculating total packet delay (#507)

This commit is contained in:
Jędrzej Stuczyński
2021-01-29 10:18:03 +00:00
committed by GitHub
parent 2314baf0d3
commit 3a261d22f5
2 changed files with 4 additions and 2 deletions
@@ -72,7 +72,8 @@ impl SURBAck {
.build_packet(surb_ack_payload, &route, &destination, &delays)
.unwrap();
let expected_total_delay = delays.iter().sum();
// in our case, the last hop is a gateway that does NOT do any delays
let expected_total_delay = delays.iter().take(delays.len() - 1).sum();
let first_hop_address =
NymNodeRoutingAddress::try_from(route.first().unwrap().address).unwrap();
+2 -1
View File
@@ -331,7 +331,8 @@ where
Ok(PreparedFragment {
// the round-trip delay is the sum of delays of all hops on the forward route as
// well as the total delay of the ack packet.
total_delay: delays.iter().sum::<Delay>() + ack_delay,
// note that the last hop of the packet is a gateway that does not do any delays
total_delay: delays.iter().take(delays.len() - 1).sum::<Delay>() + ack_delay,
mix_packet: MixPacket::new(first_hop_address, sphinx_packet, self.mode),
})
}