Light clippy(fy) (#9473)

* wasm tests

* `clippyfy` light-client

* Revert inefficient change `collect_ready()`
This commit is contained in:
Niklas Adolfsson
2018-09-06 15:44:40 +02:00
committed by Afri Schoedon
parent 4e8e5bbb86
commit 6888a968f9
22 changed files with 323 additions and 345 deletions

View File

@@ -362,7 +362,7 @@ impl SyncProvider for EthSync {
remote_address: session_info.remote_address,
local_address: session_info.local_address,
eth_info: eth_sync.peer_info(&peer_id),
pip_info: light_proto.as_ref().and_then(|lp| lp.peer_status(&peer_id)).map(Into::into),
pip_info: light_proto.as_ref().and_then(|lp| lp.peer_status(peer_id)).map(Into::into),
})
}).collect()
}).unwrap_or_else(Vec::new)
@@ -922,7 +922,7 @@ impl LightSyncProvider for LightSync {
remote_address: session_info.remote_address,
local_address: session_info.local_address,
eth_info: None,
pip_info: self.proto.peer_status(&peer_id).map(Into::into),
pip_info: self.proto.peer_status(peer_id).map(Into::into),
})
}).collect()
}).unwrap_or_else(Vec::new)

View File

@@ -183,7 +183,7 @@ impl Fetcher {
let headers = ctx.data();
if headers.len() == 0 {
if headers.is_empty() {
trace!(target: "sync", "Punishing peer {} for empty response", ctx.responder());
ctx.punish_responder();
@@ -204,20 +204,19 @@ impl Fetcher {
Ok(headers) => {
let mut parent_hash = None;
for header in headers {
if parent_hash.as_ref().map_or(false, |h| h != &header.hash()) {
trace!(target: "sync", "Punishing peer {} for parent mismatch", ctx.responder());
ctx.punish_responder();
self.requests.push(request);
return SyncRound::Fetch(self);
if let Some(hash) = parent_hash.as_ref() {
if *hash != header.hash() {
trace!(target: "sync", "Punishing peer {} for parent mismatch", ctx.responder());
ctx.punish_responder();
self.requests.push(request);
return SyncRound::Fetch(self);
}
}
// incrementally update the frame request as we go so we can
// return at any time in the loop.
parent_hash = Some(header.parent_hash().clone());
parent_hash = Some(*header.parent_hash());
request.headers_request.start = header.parent_hash().clone().into();
request.headers_request.max -= 1;
request.downloaded.push_front(header);
}
@@ -379,7 +378,7 @@ impl RoundStart {
match response::verify(ctx.data(), &req) {
Ok(headers) => {
if self.sparse_headers.len() == 0
if self.sparse_headers.is_empty()
&& headers.get(0).map_or(false, |x| x.parent_hash() != &self.start_block.1) {
trace!(target: "sync", "Wrong parent for first header in round");
ctx.punish_responder(); // or should we reset?

View File

@@ -164,7 +164,7 @@ impl PeerLike for Peer {
fn on_connect(&self, other: PeerId) {
let io = self.io(Some(other));
self.proto.on_connect(&other, &io);
self.proto.on_connect(other, &io);
}
fn on_disconnect(&self, other: PeerId){
@@ -174,7 +174,7 @@ impl PeerLike for Peer {
fn receive_message(&self, from: PeerId, msg: TestPacket) -> HashSet<PeerId> {
let io = self.io(Some(from));
self.proto.handle_packet(&io, &from, msg.packet_id, &msg.data);
self.proto.handle_packet(&io, from, msg.packet_id, &msg.data);
io.to_disconnect.into_inner()
}