fixed node penalizing

This commit is contained in:
Svyatoslav Nikolsky 2017-08-11 11:05:34 +03:00
parent 0e9b5fd89e
commit 72c3408b8f
1 changed files with 6 additions and 1 deletions

View File

@ -210,12 +210,18 @@ impl PeersTasks {
// it was requested block => update block response time
self.stats.get_mut(&peer_index)
.map(|br| {
if br.failures > 0 {
br.failures -= 1;
}
br.trust = TrustLevel::Trusted;
br.speed.checkpoint()
});
// if it hasn't been last requested block => just return
if !is_last_requested_block_received {
let mut peer_blocks_requests = self.blocks_requests.remove(&peer_index).expect("checked above; qed");
peer_blocks_requests.timestamp = precise_time_s();
self.blocks_requests.insert(peer_index, peer_blocks_requests);
return;
}
@ -223,7 +229,6 @@ impl PeersTasks {
self.stats.get_mut(&peer_index).map(|br| br.speed.stop());
// mark this peer as idle for blocks request
self.blocks_requests.remove(&peer_index);
self.idle_for_blocks.insert(peer_index);
// also mark as available for headers request if not yet
if !self.headers_requests.contains_key(&peer_index) {