Skip to content
Snippets Groups Projects
Commit 44db5f44 authored by Pierre Krieger's avatar Pierre Krieger Committed by Arkadiy Paronyan
Browse files

Directly connect if notice that ban has expired (#2100)

parent b6c54b5c
No related merge requests found
......@@ -332,15 +332,33 @@ impl<TMessage, TSubstream> CustomProto<TMessage, TSubstream> {
};
match mem::replace(occ_entry.get_mut(), PeerState::Poisoned) {
PeerState::Banned { until } => {
PeerState::Banned { ref until } if *until > Instant::now() => {
debug!(target: "sub-libp2p", "PSM => Connect({:?}): Will start to connect at \
until {:?}", occ_entry.key(), until);
*occ_entry.into_mut() = PeerState::PendingRequest {
timer: tokio_timer::Delay::new(until),
timer: tokio_timer::Delay::new(until.clone()),
};
},
PeerState::Disabled { open, connected_point, banned_until: None } => {
PeerState::Banned { .. } => {
debug!(target: "sub-libp2p", "PSM => Connect({:?}): Starting to connect", occ_entry.key());
debug!(target: "sub-libp2p", "Libp2p <= Dial {:?}", occ_entry.key());
self.events.push(NetworkBehaviourAction::DialPeer { peer_id: occ_entry.key().clone() });
*occ_entry.into_mut() = PeerState::Requested;
},
PeerState::Disabled { open, ref connected_point, banned_until: Some(ref banned) }
if *banned > Instant::now() => {
debug!(target: "sub-libp2p", "PSM => Connect({:?}): Has idle connection through \
{:?} but node is banned until {:?}", occ_entry.key(), connected_point, banned);
*occ_entry.into_mut() = PeerState::DisabledPendingEnable {
connected_point: connected_point.clone(),
open,
timer: tokio_timer::Delay::new(banned.clone()),
};
},
PeerState::Disabled { open, connected_point, banned_until: _ } => {
debug!(target: "sub-libp2p", "PSM => Connect({:?}): Enabling previously-idle \
connection through {:?}", occ_entry.key(), connected_point);
debug!(target: "sub-libp2p", "Handler({:?}) <= Enable", occ_entry.key());
......@@ -351,16 +369,6 @@ impl<TMessage, TSubstream> CustomProto<TMessage, TSubstream> {
*occ_entry.into_mut() = PeerState::Enabled { connected_point, open };
},
PeerState::Disabled { open, connected_point, banned_until: Some(banned) } => {
debug!(target: "sub-libp2p", "PSM => Connect({:?}): Has idle connection through \
{:?} but node is banned until {:?}", occ_entry.key(), connected_point, banned);
*occ_entry.into_mut() = PeerState::DisabledPendingEnable {
connected_point,
open,
timer: tokio_timer::Delay::new(banned),
};
},
PeerState::Incoming { connected_point, .. } => {
debug!(target: "sub-libp2p", "PSM => Connect({:?}): Enabling incoming \
connection through {:?}", occ_entry.key(), connected_point);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment