From a7a326ee074e580d95323e2465166761f626b7de Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Tue, 25 May 2021 13:03:35 +0200 Subject: [PATCH] Make sure nodes don't hammer each other even when reserved (#8901) * Make sure nodes don't hammer each other even when reserved * Make the ban random --- .../client/network/src/protocol/notifications/behaviour.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/substrate/client/network/src/protocol/notifications/behaviour.rs b/substrate/client/network/src/protocol/notifications/behaviour.rs index 84f15c8be3..f95f6870e5 100644 --- a/substrate/client/network/src/protocol/notifications/behaviour.rs +++ b/substrate/client/network/src/protocol/notifications/behaviour.rs @@ -1851,9 +1851,10 @@ impl NetworkBehaviour for Notifications { trace!(target: "sub-libp2p", "PSM <= Dropped({:?})", source); self.peerset.dropped(set_id, source.clone(), sc_peerset::DropReason::Refused); + let ban_dur = Uniform::new(5, 10).sample(&mut rand::thread_rng()); *entry.into_mut() = PeerState::Disabled { connections, - backoff_until: None + backoff_until: Some(Instant::now() + Duration::from_secs(ban_dur)) }; } else { *entry.into_mut() = PeerState::Enabled { connections };