Apply clippy lints to beacon node

This commit is contained in:
Age Manning
2019-11-28 14:06:46 +11:00
parent 2bbac2ed18
commit 6f2fc7560a
11 changed files with 42 additions and 52 deletions

View File

@@ -210,7 +210,7 @@ impl<TSubstream: AsyncRead + AsyncWrite> Behaviour<TSubstream> {
/// Publishes a message on the pubsub (gossipsub) behaviour.
pub fn publish(&mut self, topics: &[Topic], message: PubsubMessage) {
let message_data = message.to_data();
let message_data = message.into_data();
for topic in topics {
self.gossipsub.publish(topic, message_data.clone());
}
@@ -295,7 +295,7 @@ impl PubsubMessage {
* Also note that a message can be associated with many topics. As soon as one of the topics is
* known we match. If none of the topics are known we return an unknown state.
*/
fn from_topics(topics: &Vec<TopicHash>, data: Vec<u8>) -> Self {
fn from_topics(topics: &[TopicHash], data: Vec<u8>) -> Self {
for topic in topics {
// compare the prefix and postfix, then match on the topic
let topic_parts: Vec<&str> = topic.as_str().split('/').collect();
@@ -316,7 +316,7 @@ impl PubsubMessage {
PubsubMessage::Unknown(data)
}
fn to_data(self) -> Vec<u8> {
fn into_data(self) -> Vec<u8> {
match self {
PubsubMessage::Block(data)
| PubsubMessage::Attestation(data)

View File

@@ -174,7 +174,6 @@ where
}
/// Opens an outbound substream with a request.
#[inline]
pub fn send_request(&mut self, rpc_event: RPCEvent) {
self.keep_alive = KeepAlive::Yes;
@@ -194,12 +193,10 @@ where
type OutboundProtocol = RPCRequest;
type OutboundOpenInfo = RPCEvent; // Keep track of the id and the request
#[inline]
fn listen_protocol(&self) -> SubstreamProtocol<Self::InboundProtocol> {
self.listen_protocol.clone()
}
#[inline]
fn inject_fully_negotiated_inbound(
&mut self,
out: <RPCProtocol as InboundUpgrade<TSubstream>>::Output,
@@ -226,7 +223,6 @@ where
self.current_substream_id += 1;
}
#[inline]
fn inject_fully_negotiated_outbound(
&mut self,
out: <RPCRequest as OutboundUpgrade<TSubstream>>::Output,
@@ -272,7 +268,6 @@ where
// Note: If the substream has closed due to inactivity, or the substream is in the
// wrong state a response will fail silently.
#[inline]
fn inject_event(&mut self, rpc_event: Self::InEvent) {
match rpc_event {
RPCEvent::Request(_, _) => self.send_request(rpc_event),
@@ -347,7 +342,6 @@ where
}
}
#[inline]
fn inject_dial_upgrade_error(
&mut self,
_: Self::OutboundOpenInfo,
@@ -360,7 +354,6 @@ where
}
}
#[inline]
fn connection_keep_alive(&self) -> KeepAlive {
self.keep_alive
}
@@ -412,7 +405,7 @@ where
// Drain all queued items until all messages have been processed for this stream
// TODO Improve this code logic
let mut new_items_to_send = true;
while new_items_to_send == true {
while new_items_to_send {
new_items_to_send = false;
match self.inbound_substreams.entry(request_id) {
Entry::Occupied(mut entry) => {
@@ -514,7 +507,7 @@ where
entry.get_mut().0 =
OutboundSubstreamState::RequestPendingResponse {
substream,
request: request,
request,
};
let delay_key = &entry.get().1;
self.outbound_substreams_delay

View File

@@ -22,8 +22,11 @@ use std::time::Duration;
use tokio::io::{AsyncRead, AsyncWrite};
pub(crate) mod codec;
#[allow(clippy::type_complexity)]
#[allow(clippy::congitive_complexity)]
mod handler;
pub mod methods;
#[allow(clippy::type_complexity)]
mod protocol;
/// The return type used in the behaviour and the resultant event from the protocols handler.
@@ -77,7 +80,7 @@ impl<TSubstream> RPC<TSubstream> {
RPC {
events: Vec::new(),
marker: PhantomData,
log: log,
log,
}
}

View File

@@ -133,14 +133,7 @@ impl Service {
topics.push(topic_builder(ATTESTER_SLASHING_TOPIC));
// Add any topics specified by the user
topics.append(
&mut config
.topics
.iter()
.cloned()
.map(|s| Topic::new(s))
.collect(),
);
topics.append(&mut config.topics.iter().cloned().map(Topic::new).collect());
let mut subscribed_topics = vec![];
for topic in topics {