From 3a261d22f529ff04bc9734fcf2946fbbf9477293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Fri, 29 Jan 2021 10:18:03 +0000 Subject: [PATCH] Not including gateway non-delay when calculating total packet delay (#507) --- common/nymsphinx/acknowledgements/src/surb_ack.rs | 3 ++- common/nymsphinx/src/preparer/mod.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/nymsphinx/acknowledgements/src/surb_ack.rs b/common/nymsphinx/acknowledgements/src/surb_ack.rs index e1edd16e63..81b5ecf760 100644 --- a/common/nymsphinx/acknowledgements/src/surb_ack.rs +++ b/common/nymsphinx/acknowledgements/src/surb_ack.rs @@ -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(); diff --git a/common/nymsphinx/src/preparer/mod.rs b/common/nymsphinx/src/preparer/mod.rs index 3e074b9e5f..b1fbff575e 100644 --- a/common/nymsphinx/src/preparer/mod.rs +++ b/common/nymsphinx/src/preparer/mod.rs @@ -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::() + 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::() + ack_delay, mix_packet: MixPacket::new(first_hop_address, sphinx_packet, self.mode), }) }