Added a disconnect for sockets with 3+ spurious wakeups.

This commit is contained in:
Revertron
2021-04-02 15:25:56 +02:00
parent bc0726d3f9
commit db6b96f8dc
2 changed files with 29 additions and 3 deletions
+14
View File
@@ -15,6 +15,7 @@ pub struct Peer {
public: bool,
active: bool,
reconnects: u32,
spurious: u32,
received_block: u64,
fork: HashMap<u64, Block>
}
@@ -31,6 +32,7 @@ impl Peer {
public: false,
active: false,
reconnects: 0,
spurious: 0,
received_block: 0,
fork: HashMap::new()
}
@@ -108,6 +110,18 @@ impl Peer {
self.reconnects = 0;
}
pub fn spurious(&self) -> u32 {
self.spurious
}
pub fn inc_spurious(&mut self) {
self.spurious += 1;
}
pub fn reset_spurious(&mut self) {
self.spurious = 0;
}
pub fn disabled(&self) -> bool {
self.state.disabled() || self.reconnects > 2
}