Fixed further linter warnings
This commit is contained in:
@@ -29,11 +29,10 @@ impl NymTopology for Topology {
|
||||
};
|
||||
let directory = Client::new(directory_config);
|
||||
|
||||
let topology = directory
|
||||
directory
|
||||
.presence_topology
|
||||
.get()
|
||||
.expect("Failed to retrieve network topology.");
|
||||
topology
|
||||
.expect("Failed to retrieve network topology.")
|
||||
}
|
||||
|
||||
fn new_from_nodes(
|
||||
|
||||
@@ -46,19 +46,19 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
|
||||
}?;
|
||||
|
||||
fs::write(
|
||||
custom_location.unwrap_or(self.config_directory().join(Self::config_file_name())),
|
||||
custom_location
|
||||
.unwrap_or_else(|| self.config_directory().join(Self::config_file_name())),
|
||||
templated_config,
|
||||
)
|
||||
}
|
||||
|
||||
fn load_from_file(custom_location: Option<PathBuf>, id: Option<&str>) -> io::Result<Self> {
|
||||
let config_contents = fs::read_to_string(
|
||||
custom_location.unwrap_or(Self::default_config_directory(id).join("config.toml")),
|
||||
custom_location
|
||||
.unwrap_or_else(|| Self::default_config_directory(id).join("config.toml")),
|
||||
)?;
|
||||
|
||||
let parsing_result = toml::from_str(&config_contents)
|
||||
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err));
|
||||
|
||||
parsing_result
|
||||
toml::from_str(&config_contents)
|
||||
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub trait NymTopology: Sized + std::fmt::Debug + Send + Sync {
|
||||
}
|
||||
highest_layer = max(highest_layer, mix.layer);
|
||||
|
||||
let layer_nodes = layered_topology.entry(mix.layer).or_insert(Vec::new());
|
||||
let layer_nodes = layered_topology.entry(mix.layer).or_insert_with(Vec::new);
|
||||
layer_nodes.push(mix);
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ pub trait NymTopology: Sized + std::fmt::Debug + Send + Sync {
|
||||
if !layered_topology.contains_key(&layer) {
|
||||
missing_layers.push(layer);
|
||||
}
|
||||
if layered_topology[&layer].len() == 0 {
|
||||
if layered_topology[&layer].is_empty() {
|
||||
missing_layers.push(layer);
|
||||
}
|
||||
}
|
||||
|
||||
if missing_layers.len() > 0 {
|
||||
if !missing_layers.is_empty() {
|
||||
return Err(NymTopologyError::MissingLayerError(missing_layers));
|
||||
}
|
||||
|
||||
@@ -112,10 +112,7 @@ pub trait NymTopology: Sized + std::fmt::Debug + Send + Sync {
|
||||
}
|
||||
|
||||
fn can_construct_path_through(&self) -> bool {
|
||||
match self.make_layered_topology() {
|
||||
Ok(_) => true,
|
||||
Err(_) => false,
|
||||
}
|
||||
self.make_layered_topology().is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,12 @@ impl MixPeer {
|
||||
}
|
||||
|
||||
pub async fn send(&self, bytes: Vec<u8>) -> Result<(), Box<dyn Error>> {
|
||||
let next_hop_address = self.connection.clone();
|
||||
let mut stream = tokio::net::TcpStream::connect(next_hop_address).await?;
|
||||
let mut stream = tokio::net::TcpStream::connect(self.connection).await?;
|
||||
stream.write_all(&bytes).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn to_string(&self) -> String {
|
||||
pub fn stringify(&self) -> String {
|
||||
self.connection.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ impl PacketProcessor {
|
||||
|
||||
if forwarding_data
|
||||
.sent_metrics_tx
|
||||
.send(forwarding_data.recipient.to_string())
|
||||
.send(forwarding_data.recipient.stringify())
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user