From c71a1ae71d10c3dca9356fa2c4240800537b4ab8 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Thu, 27 Feb 2020 13:08:25 +0000 Subject: [PATCH] Changes due to updated sphinx --- Cargo.lock | 2 +- common/healthcheck/src/path_check.rs | 2 +- mixnode/src/node/packet_processing.rs | 15 +++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9168cb857f..1d5206d34b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2271,7 +2271,7 @@ dependencies = [ [[package]] name = "sphinx" version = "0.1.0" -source = "git+https://github.com/nymtech/sphinx?rev=e5d91f87a6a9dbfc192a029e834b39a42768e9ce#e5d91f87a6a9dbfc192a029e834b39a42768e9ce" +source = "git+https://github.com/nymtech/sphinx?rev=4e51ed38a5de6fcb454c8903f1fe5e6b52720c77#4e51ed38a5de6fcb454c8903f1fe5e6b52720c77" dependencies = [ "aes-ctr", "arrayref", diff --git a/common/healthcheck/src/path_check.rs b/common/healthcheck/src/path_check.rs index 79f2f80537..3a64043706 100644 --- a/common/healthcheck/src/path_check.rs +++ b/common/healthcheck/src/path_check.rs @@ -238,7 +238,7 @@ impl PathChecker { // we already checked for 'None' case let first_node_client = first_node_client.as_ref().unwrap(); - let delays: Vec<_> = path.iter().map(|_| Delay::new(0)).collect(); + let delays: Vec<_> = path.iter().map(|_| Delay::new_from_nanos(0)).collect(); // all of the data used to create the packet was created by us let packet = sphinx::SphinxPacket::new( diff --git a/mixnode/src/node/packet_processing.rs b/mixnode/src/node/packet_processing.rs index 0a8ab92d29..ad9eb66730 100644 --- a/mixnode/src/node/packet_processing.rs +++ b/mixnode/src/node/packet_processing.rs @@ -5,10 +5,10 @@ use log::*; use sphinx::header::delays::Delay as SphinxDelay; use sphinx::route::NodeAddressBytes; use sphinx::{ProcessedPacket, SphinxPacket}; +use std::net::SocketAddr; use std::ops::Deref; use std::sync::Arc; use std::time::Duration; -use std::net::SocketAddr; #[derive(Debug)] pub enum MixProcessingError { @@ -40,7 +40,6 @@ impl From for MixProcessingError { } } - // PacketProcessor contains all data required to correctly unwrap and forward sphinx packets #[derive(Clone)] pub struct PacketProcessor { @@ -58,7 +57,7 @@ impl PacketProcessor { metrics_reporter, } } - + pub(crate) fn report_sent(&self, addr: SocketAddr) { self.metrics_reporter.report_sent(addr.to_string()) } @@ -72,13 +71,13 @@ impl PacketProcessor { let next_hop_address = addressing::socket_address_from_encoded_bytes(forward_address.to_bytes())?; - // TODO: change the calls after merge on sphinx PR - let delay_duration = Duration::from_nanos(delay.get_value()); - // Delay packet for as long as required - tokio::time::delay_for(delay_duration).await; + tokio::time::delay_for(delay.to_duration()).await; - Ok(MixProcessingResult::ForwardHop(next_hop_address, packet.to_bytes())) + Ok(MixProcessingResult::ForwardHop( + next_hop_address, + packet.to_bytes(), + )) } pub(crate) async fn process_sphinx_packet(