diff --git a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs index 16296c0..b71e90e 100644 --- a/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs +++ b/colmeia-bins/src/bin/colmeia-hyperswarm-dht.rs @@ -28,6 +28,7 @@ fn main() { .unwrap_or_else(|| "10".into()) .parse::() .expect("Could not parse duration into a number"); + let duration = Duration::from_secs(duration); env_logger::init(); @@ -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"); diff --git a/colmeia-bins/src/bin/colmeia-url-meta.rs b/colmeia-bins/src/bin/colmeia-url-meta.rs index a00715c..0f73144 100644 --- a/colmeia-bins/src/bin/colmeia-url-meta.rs +++ b/colmeia-bins/src/bin/colmeia-url-meta.rs @@ -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"); diff --git a/colmeia-hypercore/src/network.rs b/colmeia-hypercore/src/network.rs index d8c14ef..001fda8 100644 --- a/colmeia-hypercore/src/network.rs +++ b/colmeia-hypercore/src/network.rs @@ -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 @@ -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 { @@ -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?; } @@ -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() @@ -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 + Unpin + Send + 'static, diff --git a/colmeia-hyperdrive/src/schema.rs b/colmeia-hyperdrive/src/schema.rs index c02c661..766b108 100644 --- a/colmeia-hyperdrive/src/schema.rs +++ b/colmeia-hyperdrive/src/schema.rs @@ -6,7 +6,7 @@ #![allow(clippy::all)] #![allow(unused_attributes)] -#![rustfmt::skip] +#![cfg_attr(rustfmt, rustfmt_skip)] #![allow(box_pointers)] #![allow(dead_code)] diff --git a/colmeia-hyperstack/src/hyperstack.rs b/colmeia-hyperstack/src/hyperstack.rs index 6eee675..1392e21 100644 --- a/colmeia-hyperstack/src/hyperstack.rs +++ b/colmeia-hyperstack/src/hyperstack.rs @@ -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; @@ -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) } diff --git a/colmeia-hyperswarm-mdns/src/locator.rs b/colmeia-hyperswarm-mdns/src/locator.rs index 4568a05..a839526 100644 --- a/colmeia-hyperswarm-mdns/src/locator.rs +++ b/colmeia-hyperswarm-mdns/src/locator.rs @@ -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::().ok()?; - return Some(SocketAddr::new(IpAddr::V4(target_ipv4), port)); } + + let target_ipv4 = srv_data.target().to_utf8().parse::().ok()?; + return Some(SocketAddr::new(IpAddr::V4(target_ipv4), port)); } None }