Implements a timeout for peer banning (#665)

* Adds peer ban timeout of 30 seconds

* Remove delay queue from discovery
This commit is contained in:
Age Manning
2019-12-06 14:13:43 +11:00
committed by Paul Hauner
parent 5e8f958977
commit 5a765396b7
14 changed files with 92 additions and 50 deletions

View File

@@ -39,7 +39,7 @@ pub struct Discovery<TSubstream> {
/// The target number of connected peers on the libp2p interface.
max_peers: usize,
/// directory to save ENR to
/// The directory where the ENR is stored.
enr_dir: String,
/// The delay between peer discovery searches.
@@ -158,11 +158,14 @@ impl<TSubstream> Discovery<TSubstream> {
/// The peer has been banned. Add this peer to the banned list to prevent any future
/// re-connections.
// TODO: Remove the peer from the DHT if present
// TODO: Implement a timeout, after which we unban the peer
pub fn peer_banned(&mut self, peer_id: PeerId) {
self.banned_peers.insert(peer_id);
}
pub fn peer_unbanned(&mut self, peer_id: &PeerId) {
self.banned_peers.remove(peer_id);
}
/// Search for new peers using the underlying discovery mechanism.
fn find_peers(&mut self) {
// pick a random NodeId