From 56d5230ee7afcbf8adbe9baf354bfad813c7c48d Mon Sep 17 00:00:00 2001 From: yashablack Date: Sun, 7 May 2023 21:33:28 +0300 Subject: [PATCH] feat: impl BanPeer --- spectrum-network/src/network_controller.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spectrum-network/src/network_controller.rs b/spectrum-network/src/network_controller.rs index e6d11570..ce6629c2 100644 --- a/spectrum-network/src/network_controller.rs +++ b/spectrum-network/src/network_controller.rs @@ -7,6 +7,7 @@ use std::time::{Duration, Instant}; use either::{Either, Left, Right}; use futures::channel::mpsc::{Receiver, Sender}; use futures::{SinkExt, Stream}; +use libp2p::allow_block_list::{Behaviour, BlockedPeers}; use libp2p::core::Endpoint; use libp2p::swarm::behaviour::ConnectionEstablished; use libp2p::swarm::{ @@ -262,6 +263,7 @@ pub struct NetworkController { pending_one_shot_requests: HashMap, requests_recv: Receiver, pending_actions: VecDeque>, + blocked_list: Behaviour, } impl NetworkController @@ -284,6 +286,7 @@ where pending_one_shot_requests: HashMap::new(), requests_recv, pending_actions: VecDeque::new(), + blocked_list: Behaviour::default(), } } @@ -819,7 +822,7 @@ where } } NetworkControllerIn::BanPeer(pid) => { - //todo: Ban peer; DEV-941 + self.blocked_list.block_peer(pid); } } continue;