From ff4284a3b92573d45baf437cb3004fdffc662596 Mon Sep 17 00:00:00 2001 From: Jedrzej Stuczynski Date: Tue, 3 Mar 2020 12:44:37 +0000 Subject: [PATCH] Redundant code in mix handling --- sfw-provider/src/provider/mix_handling/mod.rs | 7 ------- .../src/provider/mix_handling/packet_processing.rs | 13 ++++++++++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sfw-provider/src/provider/mix_handling/mod.rs b/sfw-provider/src/provider/mix_handling/mod.rs index ad8693dddb..236fd73481 100644 --- a/sfw-provider/src/provider/mix_handling/mod.rs +++ b/sfw-provider/src/provider/mix_handling/mod.rs @@ -1,9 +1,2 @@ -use crate::provider::storage::StoreData; -use crypto::encryption; -use log::{error, warn}; -use sphinx::{ProcessedPacket, SphinxPacket}; -use std::path::PathBuf; -use std::sync::{Arc, RwLock}; - pub(crate) mod listener; pub(crate) mod packet_processing; diff --git a/sfw-provider/src/provider/mix_handling/packet_processing.rs b/sfw-provider/src/provider/mix_handling/packet_processing.rs index f7c2d6098e..12d50c322c 100644 --- a/sfw-provider/src/provider/mix_handling/packet_processing.rs +++ b/sfw-provider/src/provider/mix_handling/packet_processing.rs @@ -1,7 +1,10 @@ use crate::provider::storage::{ClientStorage, StoreData}; use crypto::encryption; +use log::*; +use sphinx::payload::Payload; use sphinx::route::{DestinationAddressBytes, SURBIdentifier}; use sphinx::{ProcessedPacket, SphinxPacket}; +use std::io; use std::ops::Deref; use std::sync::Arc; @@ -11,7 +14,7 @@ pub enum MixProcessingError { NonMatchingRecipient, InvalidPayload, SphinxProcessingError, - InvalidHopAddress, + IOError(String), } pub enum MixProcessingResult { @@ -29,6 +32,14 @@ impl From for MixProcessingError { } } +impl From for MixProcessingError { + fn from(e: io::Error) -> Self { + use MixProcessingError::*; + + IOError(e.to_string()) + } +} + // PacketProcessor contains all data required to correctly unwrap and store sphinx packets #[derive(Clone)] pub struct PacketProcessor {