Apply clippy suggestions

This commit is contained in:
Age Manning
2019-03-19 23:20:39 +11:00
parent e7f87112fb
commit 4b57d32b60
9 changed files with 30 additions and 43 deletions

View File

@@ -13,7 +13,7 @@ use libp2p::core::swarm::{
use libp2p::{Multiaddr, PeerId};
pub use methods::{HelloMessage, RPCMethod, RPCRequest, RPCResponse};
pub use protocol::{RPCEvent, RPCProtocol};
use slog::{debug, o};
use slog::o;
use std::marker::PhantomData;
use tokio::io::{AsyncRead, AsyncWrite};
@@ -65,7 +65,7 @@ where
fn inject_connected(&mut self, peer_id: PeerId, connected_point: ConnectedPoint) {
// if initialised the connection, report this upwards to send the HELLO request
if let ConnectedPoint::Dialer { address } = connected_point {
if let ConnectedPoint::Dialer { address: _ } = connected_point {
self.events.push(NetworkBehaviourAction::GenerateEvent(
RPCMessage::PeerDialed(peer_id),
));

View File

@@ -84,11 +84,11 @@ fn decode(packet: Vec<u8>) -> Result<RPCEvent, DecodeError> {
RPCMethod::Unknown => return Err(DecodeError::UnknownRPCMethod),
};
return Ok(RPCEvent::Request {
Ok(RPCEvent::Request {
id,
method_id,
body,
});
})
}
// we have received a response
else {
@@ -99,11 +99,11 @@ fn decode(packet: Vec<u8>) -> Result<RPCEvent, DecodeError> {
}
RPCMethod::Unknown => return Err(DecodeError::UnknownRPCMethod),
};
return Ok(RPCEvent::Response {
Ok(RPCEvent::Response {
id,
method_id,
result,
});
})
}
}

View File

@@ -73,13 +73,12 @@ impl Service {
let mut subscribed_topics = vec![];
for topic in config.topics {
let t = TopicBuilder::new(topic.to_string()).build();
match swarm.subscribe(t) {
true => {
trace!(log, "Subscribed to topic: {:?}", topic);
subscribed_topics.push(topic);
}
false => warn!(log, "Could not subscribe to topic: {:?}", topic),
};
if swarm.subscribe(t) {
trace!(log, "Subscribed to topic: {:?}", topic);
subscribed_topics.push(topic);
} else {
warn!(log, "Could not subscribe to topic: {:?}", topic)
}
}
info!(log, "Subscribed to topics: {:?}", subscribed_topics);