Merge pull request #106 from ikatson/resilience-to-bogus-peers

Fix resilience to bogus peers
This commit is contained in:
Igor Katson 2024-03-29 20:46:37 +00:00 committed by GitHub
commit bb0f3c36ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 38 additions and 8 deletions

View file

@ -1396,11 +1396,15 @@ impl PeerHandler {
self.state.maybe_transmit_haves(chunk_info.piece_index);
}
false => {
warn!("checksum for piece={} did not validate", index,);
warn!(
"checksum for piece={} did not validate. disconecting peer.",
index
);
self.state
.lock_write("mark_piece_broken")
.get_chunks_mut()?
.mark_piece_broken_if_not_have(chunk_info.piece_index);
anyhow::bail!("i am probably a bogus peer. dying.")
}
};
Ok::<_, anyhow::Error>(())