Skip to content

Commit

Permalink
feat: ban a peer if its last state isn't changed after timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
yangby-cryptape committed Dec 29, 2023
1 parent 74cbc3c commit b553660
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/protocols/light_client/peers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,6 +1856,15 @@ impl Peers {
None
}
})
.or_else(|| {
peer.state.get_last_state().and_then(|state| {
if now > state.update_ts + MESSAGE_TIMEOUT {
Some(*peer_index)
} else {
None
}
})
})
.or_else(|| {
peer.get_blocks_proof_request().and_then(|req| {
if now > req.when_sent + MESSAGE_TIMEOUT {
Expand Down

0 comments on commit b553660

Please sign in to comment.