Skip to content

Commit

Permalink
Fix other clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
bltavares committed May 17, 2021
1 parent 359dac5 commit d791cb8
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fn main() {
.unwrap_or_else(|| "10".into())
.parse::<u64>()
.expect("Could not parse duration into a number");
let duration = Duration::from_secs(duration);

env_logger::init();

Expand All @@ -48,7 +49,7 @@ fn main() {
.await
.expect("could not start announcer");

let mut locator = Locator::listen(&config, duration)
let mut locator = Locator::listen(&config, Duration::from_secs(1))
.await
.expect("Could not start locator");

Expand Down
2 changes: 1 addition & 1 deletion colmeia-bins/src/bin/colmeia-url-meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn main() {
}
}

fn invalid_public_key(e: HashParserError) -> () {
fn invalid_public_key(e: HashParserError) {
match e {
HashParserError::InvalidHexHash(_) => {
eprintln!("Invalid hyper url");
Expand Down
11 changes: 8 additions & 3 deletions colmeia-hypercore/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where
nodes: message
.nodes
.iter()
.map(|node| hypercore::Node::new(node.index, node.hash.to_vec(), node.size))
.map(|node| hypercore::Node::new(node.index, node.hash.clone(), node.size))
.collect(),
signature: message
.signature
Expand Down Expand Up @@ -88,6 +88,7 @@ where
// self.remoteLength = self.remoteBitfield.last() + 1;
}
} else {
#[allow(clippy::cast_possible_truncation)]
let mut start = message.start as usize;
let len = message.length.unwrap_or(1);
for _ in 0..len {
Expand All @@ -108,7 +109,7 @@ where
for index in 0..=message.start {
let request = proto::schema::Request {
index,
..Default::default()
..proto::schema::Request::default()
};
self.channel.request(request).await?;
}
Expand All @@ -129,10 +130,11 @@ where
// where this is contained in
let have = proto::schema::Have {
start: feed_length as u64,
..Default::default()
..proto::schema::Have::default()
};
self.channel.have(have).await?;
}
#[allow(clippy::cast_possible_truncation)]
let rle = self
.feed
.read()
Expand All @@ -149,6 +151,9 @@ where
Ok(())
}

/// # Errors
///
/// Returns the error if any of the protocol operations fail
pub async fn replicate(
&mut self,
mut rx: impl futures::Sink<Emit> + Unpin + Send + 'static,
Expand Down
2 changes: 1 addition & 1 deletion colmeia-hyperdrive/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#![allow(clippy::all)]

#![allow(unused_attributes)]
#![rustfmt::skip]
#![cfg_attr(rustfmt, rustfmt_skip)]

#![allow(box_pointers)]
#![allow(dead_code)]
Expand Down
3 changes: 1 addition & 2 deletions colmeia-hyperstack/src/hyperstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use async_std::{
task,
};
use colmeia_hyperdrive::Hyperdrive;
use colmeia_hyperswarm_dht::Config;
use ed25519_dalek::PublicKey;
use futures::{Future, Stream, StreamExt};
use hypercore_protocol::ProtocolBuilder;
Expand Down Expand Up @@ -72,7 +71,7 @@ where
let mut mdns = colmeia_hyperswarm_mdns::MdnsDiscovery::new();
mdns.with_announcer(self.listen_address.port())
.with_locator(Duration::from_secs(60)); // TODO: config
mdns.add_topic(&hypercore_protocol::discovery_key(self.key.as_bytes()))
mdns.add_topic(hypercore_protocol::discovery_key(self.key.as_bytes()))
.await?;
Ok(mdns)
}
Expand Down
6 changes: 3 additions & 3 deletions colmeia-hyperswarm-mdns/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ fn select_ip_from_hyperswarm_mdns_response(
let port = srv_data.port();
if srv_data.target() == &*crate::UNSPECIFIED_NAME {
return Some(SocketAddr::new(IpAddr::V4(*origin_ip), port));
} else {
let target_ipv4 = srv_data.target().to_utf8().parse::<Ipv4Addr>().ok()?;
return Some(SocketAddr::new(IpAddr::V4(target_ipv4), port));
}

let target_ipv4 = srv_data.target().to_utf8().parse::<Ipv4Addr>().ok()?;
return Some(SocketAddr::new(IpAddr::V4(target_ipv4), port));
}
None
}
Expand Down

0 comments on commit d791cb8

Please sign in to comment.