From ac981a09b437d98393bda097588654ad4bb2b38f Mon Sep 17 00:00:00 2001 From: Jimmy Chen Date: Tue, 2 Jul 2024 18:03:24 +1000 Subject: [PATCH] Remove unused code and update docs. --- .../src/peer_manager/peerdb.rs | 30 ------------------- .../lighthouse_network/src/types/globals.rs | 6 ++++ 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs index 10c4cb231aa..e7748090293 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs @@ -704,36 +704,6 @@ impl PeerDB { ) } - /// Updates the connection state. MUST ONLY BE USED IN TESTS. - #[cfg(test)] - pub(crate) fn __add_connected_peer_enr_testing_only( - &mut self, - enr: Enr, - ) -> Option { - let peer_id = enr.peer_id(); - let new_state = NewConnectionState::Connected { - enr: Some(enr), - seen_address: Multiaddr::empty(), - direction: ConnectionDirection::Outgoing, - }; - self.update_connection_state(&peer_id, new_state) - } - - /// Updates the connection state. MUST ONLY BE USED IN TESTS. - #[cfg(test)] - pub(crate) fn __add_connected_peer_multiaddr_testing_only( - &mut self, - peer_id: &PeerId, - multiaddr: Multiaddr, - ) -> Option { - let new_state = NewConnectionState::Connected { - enr: None, - seen_address: multiaddr, - direction: ConnectionDirection::Outgoing, - }; - self.update_connection_state(peer_id, new_state) - } - /// The connection state of the peer has been changed. Modify the peer in the db to ensure all /// variables are in sync with libp2p. /// Updating the state can lead to a `BanOperation` which needs to be processed via the peer diff --git a/beacon_node/lighthouse_network/src/types/globals.rs b/beacon_node/lighthouse_network/src/types/globals.rs index d01ad9707aa..0f99bfc5dae 100644 --- a/beacon_node/lighthouse_network/src/types/globals.rs +++ b/beacon_node/lighthouse_network/src/types/globals.rs @@ -128,6 +128,12 @@ impl NetworkGlobals { DataColumnSubnetId::compute_custody_subnets::(node_id, custody_subnet_count, spec) } + /// Returns a connected peer that: + /// 1. is connected + /// 2. assigned to custody the column based on it's `custody_subnet_count` from metadata (WIP) + /// 3. has a good score + /// 4. subscribed to the specified column - this condition can be removed later, so we can + /// identify and penalise peers that are supposed to custody the column. pub fn custody_peers_for_column( &self, column_index: ColumnIndex,