fn peerset_report_disconnect(&mut self, peer_id: PeerId) {
		let mut entry = match self.peers.entry(peer_id) {
			Entry::Occupied(entry) => entry,
			Entry::Vacant(entry) => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Node already disabled", entry.key());
				return
			}
		};

		match mem::replace(entry.get_mut(), PeerState::Poisoned) {
			st @ PeerState::Disabled { .. } | st @ PeerState::Banned { .. } => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Node already disabled", entry.key());
				*entry.into_mut() = st;
			},

			PeerState::DisabledPendingEnable { open, connected_point, timer } => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Interrupting pending \
					enable", entry.key());
				*entry.into_mut() = PeerState::Disabled {
					open,
					connected_point,
					banned_until: Some(timer.deadline()),
				};
			},

			PeerState::Enabled { open, connected_point } => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Disabling connection", entry.key());
				debug!(target: "sub-libp2p", "Handler({:?}) <= Disable", entry.key());
				self.events.push(NetworkBehaviourAction::SendEvent {
					peer_id: entry.key().clone(),
					event: CustomProtoHandlerIn::Disable,
				});
				*entry.into_mut() = PeerState::Disabled { open, connected_point, banned_until: None }
			},
			st @ PeerState::Incoming { .. } => {
				error!(target: "sub-libp2p", "PSM => Drop({:?}): Was in incoming mode",
					entry.key());
				*entry.into_mut() = st;
			},
			PeerState::Requested => {
				// We don't cancel dialing. Libp2p doesn't expose that on purpose, as other
				// sub-systems (such as the discovery mechanism) may require dialing this node as
				// well at the same time.
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Was not yet connected", entry.key());
				entry.remove();
			},
			PeerState::PendingRequest { timer } => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Was not yet connected", entry.key());
				*entry.into_mut() = PeerState::Banned { until: timer.deadline() }
			},

			PeerState::Poisoned =>
				error!(target: "sub-libp2p", "State of {:?} is poisoned", entry.key()),
		}
	}
/// Function that is called when the peerset wants us to disconnect from a node.
Function that is called when the peerset wants us to disconnect from a node.
Function that is called when the peerset wants us to disconnect from a node .
fn peerset_report_disconnect(&mut self, peer_id: PeerId) {
		let mut entry = match self.peers.entry(peer_id) {
			Entry::Occupied(entry) => entry,
			Entry::Vacant(entry) => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Node already disabled", entry.key());
				return
			}
		};
		match mem::replace(entry.get_mut(), PeerState::Poisoned) {
			st @ PeerState::Disabled { .. } | st @ PeerState::Banned { .. } => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Node already disabled", entry.key());
				*entry.into_mut() = st;
			},
			PeerState::DisabledPendingEnable { open, connected_point, timer } => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Interrupting pending \
					enable", entry.key());
				*entry.into_mut() = PeerState::Disabled {
					open,
					connected_point,
					banned_until: Some(timer.deadline()),
				};
			},
			PeerState::Enabled { open, connected_point } => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Disabling connection", entry.key());
				debug!(target: "sub-libp2p", "Handler({:?}) <= Disable", entry.key());
				self.events.push(NetworkBehaviourAction::SendEvent {
					peer_id: entry.key().clone(),
					event: CustomProtoHandlerIn::Disable,
				});
				*entry.into_mut() = PeerState::Disabled { open, connected_point, banned_until: None }
			},
			st @ PeerState::Incoming { .. } => {
				error!(target: "sub-libp2p", "PSM => Drop({:?}): Was in incoming mode",
					entry.key());
				*entry.into_mut() = st;
			},
			PeerState::Requested => {
				// We don't cancel dialing. Libp2p doesn't expose that on purpose, as other
				// sub-systems (such as the discovery mechanism) may require dialing this node as
				// well at the same time.
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Was not yet connected", entry.key());
				entry.remove();
			},
			PeerState::PendingRequest { timer } => {
				debug!(target: "sub-libp2p", "PSM => Drop({:?}): Was not yet connected", entry.key());
				*entry.into_mut() = PeerState::Banned { until: timer.deadline() }
			},
			PeerState::Poisoned =>
				error!(target: "sub-libp2p", "State of {:?} is poisoned", entry.key()),
		}
	}
fn peerset_report_disconnect ( & mut self , peer_id : PeerId ) { let mut entry = match self . peers . entry ( peer_id ) { Entry :: Occupied ( entry ) => entry , Entry :: Vacant ( entry ) => { debug ! ( target " " " " entry key ( ) ) ; return } } ; match mem :: replace ( entry . get_mut ( ) , PeerState :: Poisoned ) { st @ PeerState :: Disabled { .. } | st @ PeerState :: Banned { .. } => { debug ! ( target " " " " entry key ( ) ) ; * entry . into_mut ( ) = st ; } , PeerState :: DisabledPendingEnable { open , connected_point , timer } => { debug ! ( target " " " \
 " entry key ( ) ) ; * entry . into_mut ( ) = PeerState :: Disabled { open , connected_point , banned_until : Some ( timer . deadline ( ) ) , } ; } , PeerState :: Enabled { open , connected_point } => { debug ! ( target " " " " entry key ( ) ) ; debug ! ( target " " " " entry key ( ) ) ; self . events . push ( NetworkBehaviourAction :: SendEvent { peer_id : entry . key ( ) . clone ( ) , event : CustomProtoHandlerIn :: Disable , } ) ; * entry . into_mut ( ) = PeerState :: Disabled { open , connected_point , banned_until : None } } , st @ PeerState :: Incoming { .. } => { error ! ( target " " " " entry key ( ) ) ; * entry . into_mut ( ) = st ; } , PeerState :: Requested => { // We don't cancel dialing. Libp2p doesn't expose that on purpose, as other // sub-systems (such as the discovery mechanism) may require dialing this node as // well at the same time. debug ! ( target " " " " entry key ( ) ) ; entry . remove ( ) ; } , PeerState :: PendingRequest { timer } => { debug ! ( target " " " " entry key ( ) ) ; * entry . into_mut ( ) = PeerState :: Banned { until : timer . deadline ( ) } } , PeerState :: Poisoned => error ! ( target " " " " entry key ( ) ) , } }
Function that is called when the peerset wants us to disconnect from a node.
Function that is called when the peerset wants us to disconnect from a node .
&mut self
peer_id
PeerId
&mut self
peer_id
PeerId