fix: fraud peer ban doesn't work in some cases (#2867)

This commit is contained in:
Gary Yu 2019-05-31 08:02:54 +08:00 committed by GitHub
parent 56b62a319b
commit e345405201
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -143,13 +143,10 @@ impl HeaderSync {
if let Some(ref stalling_ts) = self.stalling_ts {
if let Some(ref peer) = self.syncing_peer {
match self.sync_state.status() {
SyncStatus::HeaderSync {
current_height: _,
highest_height,
} => {
SyncStatus::HeaderSync { .. } | SyncStatus::BodySync { .. } => {
// Ban this fraud peer which claims a higher work but can't send us the real headers
if now > *stalling_ts + Duration::seconds(120)
&& highest_height == peer.info.height()
&& header_head.total_difficulty < peer.info.total_difficulty()
{
self.peers
.ban_peer(peer.info.addr, ReasonForBan::FraudHeight);