diff --git a/beacon_node/eth2_libp2p/src/behaviour/handler/mod.rs b/beacon_node/eth2_libp2p/src/behaviour/handler/mod.rs index 605870d0f2..538c122cc7 100644 --- a/beacon_node/eth2_libp2p/src/behaviour/handler/mod.rs +++ b/beacon_node/eth2_libp2p/src/behaviour/handler/mod.rs @@ -41,15 +41,9 @@ pub enum BehaviourHandlerIn { Shutdown(Option<(RequestId, RPCRequest)>), } -pub enum BehaviourHandlerOut { - Delegate(Box>), - // TODO: replace custom with events to send - Custom, -} - impl ProtocolsHandler for BehaviourHandler { type InEvent = BehaviourHandlerIn; - type OutEvent = BehaviourHandlerOut; + type OutEvent = DelegateOut; type Error = DelegateError; type InboundProtocol = DelegateInProto; type OutboundProtocol = DelegateOutProto; @@ -122,9 +116,7 @@ impl ProtocolsHandler for BehaviourHandler { match self.delegate.poll(cx) { Poll::Ready(ProtocolsHandlerEvent::Custom(event)) => { - return Poll::Ready(ProtocolsHandlerEvent::Custom( - BehaviourHandlerOut::Delegate(Box::new(event)), - )) + return Poll::Ready(ProtocolsHandlerEvent::Custom(event)) } Poll::Ready(ProtocolsHandlerEvent::Close(err)) => { return Poll::Ready(ProtocolsHandlerEvent::Close(err)) diff --git a/beacon_node/eth2_libp2p/src/behaviour/mod.rs b/beacon_node/eth2_libp2p/src/behaviour/mod.rs index 143b59f4f9..72d60a5532 100644 --- a/beacon_node/eth2_libp2p/src/behaviour/mod.rs +++ b/beacon_node/eth2_libp2p/src/behaviour/mod.rs @@ -5,7 +5,7 @@ use crate::types::{GossipEncoding, GossipKind, GossipTopic, SubnetDiscovery}; use crate::Eth2Enr; use crate::{error, metrics, Enr, NetworkConfig, NetworkGlobals, PubsubMessage, TopicHash}; use futures::prelude::*; -use handler::{BehaviourHandler, BehaviourHandlerIn, BehaviourHandlerOut, DelegateIn, DelegateOut}; +use handler::{BehaviourHandler, BehaviourHandlerIn, DelegateIn, DelegateOut}; use libp2p::{ core::{ connection::{ConnectedPoint, ConnectionId, ListenerId}, @@ -591,7 +591,6 @@ impl Behaviour { } => { if matches!(error, RPCError::HandlerRejected) { // this peer's request got canceled - // TODO: cancel processing for this request } // Inform the peer manager of the error. // An inbound error here means we sent an error to the peer, or the stream @@ -624,8 +623,6 @@ impl Behaviour { // TODO: inform the peer manager? } RPCRequest::Goodbye(reason) => { - // let the peer manager know this peer is in the process of disconnecting - self.peer_manager._disconnecting_peer(&peer_id); // queue for disconnection without a goodbye message debug!( self.log, "Peer sent Goodbye"; @@ -975,17 +972,11 @@ impl NetworkBehaviour for Behaviour { return; } + // Events comming from the handler, redirected to each behaviour match event { - // Events comming from the handler, redirected to each behaviour - BehaviourHandlerOut::Delegate(delegate) => match *delegate { - DelegateOut::Gossipsub(ev) => self.gossipsub.inject_event(peer_id, conn_id, ev), - DelegateOut::RPC(ev) => self.eth2_rpc.inject_event(peer_id, conn_id, ev), - DelegateOut::Identify(ev) => self.identify.inject_event(peer_id, conn_id, *ev), - }, - /* Custom events sent BY the handler */ - BehaviourHandlerOut::Custom => { - // TODO: implement - } + DelegateOut::Gossipsub(ev) => self.gossipsub.inject_event(peer_id, conn_id, ev), + DelegateOut::RPC(ev) => self.eth2_rpc.inject_event(peer_id, conn_id, ev), + DelegateOut::Identify(ev) => self.identify.inject_event(peer_id, conn_id, *ev), } } @@ -1003,7 +994,6 @@ impl NetworkBehaviour for Behaviour { self.waker = Some(cx.waker().clone()); } - // TODO: move where it's less distracting macro_rules! poll_behaviour { /* $behaviour: The sub-behaviour being polled. * $on_event_fn: Function to call if we get an event from the sub-behaviour. diff --git a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs b/beacon_node/eth2_libp2p/src/peer_manager/mod.rs index d528d7e69e..47dc23d7c3 100644 --- a/beacon_node/eth2_libp2p/src/peer_manager/mod.rs +++ b/beacon_node/eth2_libp2p/src/peer_manager/mod.rs @@ -322,15 +322,6 @@ impl PeerManager { self.connect_peer(peer_id, ConnectingType::OutgoingConnected { multiaddr }) } - /// Updates the database informing that a peer is being disconnected. - pub fn _disconnecting_peer(&mut self, _peer_id: &PeerId) -> bool { - // TODO: implement - // This informs the database that we are in the process of disconnecting the - // peer. Currently this state only exists for a short period of time before we force the - // disconnection. - true - } - /// Reports if a peer is banned or not. /// /// This is used to determine if we should accept incoming connections.