fixed node penalizing
This commit is contained in:
parent
0e9b5fd89e
commit
72c3408b8f
|
@ -210,12 +210,18 @@ impl PeersTasks {
|
||||||
// it was requested block => update block response time
|
// it was requested block => update block response time
|
||||||
self.stats.get_mut(&peer_index)
|
self.stats.get_mut(&peer_index)
|
||||||
.map(|br| {
|
.map(|br| {
|
||||||
|
if br.failures > 0 {
|
||||||
|
br.failures -= 1;
|
||||||
|
}
|
||||||
br.trust = TrustLevel::Trusted;
|
br.trust = TrustLevel::Trusted;
|
||||||
br.speed.checkpoint()
|
br.speed.checkpoint()
|
||||||
});
|
});
|
||||||
|
|
||||||
// if it hasn't been last requested block => just return
|
// if it hasn't been last requested block => just return
|
||||||
if !is_last_requested_block_received {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +229,6 @@ impl PeersTasks {
|
||||||
self.stats.get_mut(&peer_index).map(|br| br.speed.stop());
|
self.stats.get_mut(&peer_index).map(|br| br.speed.stop());
|
||||||
|
|
||||||
// mark this peer as idle for blocks request
|
// mark this peer as idle for blocks request
|
||||||
self.blocks_requests.remove(&peer_index);
|
|
||||||
self.idle_for_blocks.insert(peer_index);
|
self.idle_for_blocks.insert(peer_index);
|
||||||
// also mark as available for headers request if not yet
|
// also mark as available for headers request if not yet
|
||||||
if !self.headers_requests.contains_key(&peer_index) {
|
if !self.headers_requests.contains_key(&peer_index) {
|
||||||
|
|
Loading…
Reference in New Issue