Skip to content
Snippets Groups Projects
Commit b2a56f6b authored by Éloïs's avatar Éloïs
Browse files

[clippy]

parent e53d5eaa
Branches
Tags
1 merge request!93Migrate network documents to pest
...@@ -444,7 +444,7 @@ impl BlockchainModule { ...@@ -444,7 +444,7 @@ impl BlockchainModule {
wot: &BinDB<W>, wot: &BinDB<W>,
) -> Blockstamp { ) -> Blockstamp {
debug!("BlockchainModule : receive_blocks()"); debug!("BlockchainModule : receive_blocks()");
let blocks: Vec<&NetworkBlock> = blocks_in_box.into_iter().map(|b| b.deref()).collect(); let blocks: Vec<&NetworkBlock> = blocks_in_box.iter().map(|b| b.deref()).collect();
let mut current_blockstamp = *current_blockstamp; let mut current_blockstamp = *current_blockstamp;
let mut save_blocks_dbs = false; let mut save_blocks_dbs = false;
let mut save_wots_dbs = false; let mut save_wots_dbs = false;
......
...@@ -194,7 +194,7 @@ pub struct EndpointV2NetworkFeatures(pub Vec<u8>); ...@@ -194,7 +194,7 @@ pub struct EndpointV2NetworkFeatures(pub Vec<u8>);
impl ToString for EndpointV2NetworkFeatures { impl ToString for EndpointV2NetworkFeatures {
fn to_string(&self) -> String { fn to_string(&self) -> String {
if self.is_empty() { if self.is_empty() {
return format!(""); return "".to_owned();
} }
let mut features_str = Vec::with_capacity(2); let mut features_str = Vec::with_capacity(2);
if self.tls() { if self.tls() {
...@@ -288,7 +288,7 @@ impl ToString for EndpointV2 { ...@@ -288,7 +288,7 @@ impl ToString for EndpointV2 {
let path = if let Some(ref path) = self.path { let path = if let Some(ref path) = self.path {
format!(" {}", path) format!(" {}", path)
} else { } else {
format!("") "".to_owned()
}; };
format!( format!(
"{api} {version}{nf}{af}{host}{ip4}{ip6}{port}{path}", "{api} {version}{nf}{af}{host}{ip4}{ip6}{port}{path}",
...@@ -296,7 +296,7 @@ impl ToString for EndpointV2 { ...@@ -296,7 +296,7 @@ impl ToString for EndpointV2 {
version = if self.api_version > 0 { version = if self.api_version > 0 {
format!("V{} ", self.api_version) format!("V{} ", self.api_version)
} else { } else {
format!("") "".to_owned()
}, },
nf = self.network_features.to_string(), nf = self.network_features.to_string(),
af = self.api_features.to_string(), af = self.api_features.to_string(),
......
...@@ -48,7 +48,7 @@ pub fn _self_peer_update_endpoints( ...@@ -48,7 +48,7 @@ pub fn _self_peer_update_endpoints(
} }
for ep in self_peer.endpoints_str { for ep in self_peer.endpoints_str {
let ep_clone = ep.clone(); let ep_clone = ep.clone();
let ep_fields: Vec<&str> = ep_clone.split(" ").collect(); let ep_fields: Vec<&str> = ep_clone.split(' ').collect();
if !apis.contains(&NetworkEndpointApi(ep_fields[0].to_owned())) { if !apis.contains(&NetworkEndpointApi(ep_fields[0].to_owned())) {
new_endpoints_str.push(ep); new_endpoints_str.push(ep);
} }
...@@ -56,10 +56,12 @@ pub fn _self_peer_update_endpoints( ...@@ -56,10 +56,12 @@ pub fn _self_peer_update_endpoints(
for ep in new_endpoints { for ep in new_endpoints {
if let EndpointEnum::V2(ep_v2) = ep { if let EndpointEnum::V2(ep_v2) = ep {
let bin_len = bincode::serialize(&ep_v2) let bin_len = bincode::serialize(&ep_v2)
.expect(&format!( .unwrap_or_else(|_| {
panic!(
"Fail to update self peer : invalid endpoint : {:?} !", "Fail to update self peer : invalid endpoint : {:?} !",
ep_v2, ep_v2
)) )
})
.len(); .len();
let str_ep = ep_v2.to_string(); let str_ep = ep_v2.to_string();
if str_ep.len() < bin_len { if str_ep.len() < bin_len {
...@@ -94,10 +96,12 @@ pub fn _generate_self_peer( ...@@ -94,10 +96,12 @@ pub fn _generate_self_peer(
for ep in endpoints { for ep in endpoints {
if let EndpointEnum::V2(ep_v2) = ep { if let EndpointEnum::V2(ep_v2) = ep {
let bin_len = bincode::serialize(&ep_v2) let bin_len = bincode::serialize(&ep_v2)
.expect(&format!( .unwrap_or_else(|_| {
panic!(
"Fail to generate self peer : invalid endpoint : {:?} !", "Fail to generate self peer : invalid endpoint : {:?} !",
ep_v2, ep_v2
)) )
})
.len(); .len();
let str_ep = ep_v2.to_string(); let str_ep = ep_v2.to_string();
if str_ep.len() < bin_len { if str_ep.len() < bin_len {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment