lighthouse
lighthouse copied to clipboard
Refactor PeerManager to introduce Connectivity Module
Issue Addressed
https://github.com/sigp/lighthouse/issues/6860
Proposed Changes
-
Introduction of Connectivity Struct:
- Added a new Connectivity struct that uses the NetworkGlobalsProvider trait.
- Encapsulates peer management parameters and methods such as dial_peer, peers_discovered, and maintain_peer_count.
-
NetworkGlobalsProvider Trait:
- A new trait NetworkGlobalsProvider is introduced. The idea is to create a generic and minimal invasive interface to the current code which other projects are free to decide how to implement.
- Methods include connected_outbound_only_peers, connected_or_dialing_peers, update_min_ttl, and should_dial.
-
Refactoring PeerManager:
- PeerManager now includes the Connectivity struct.
- Methods within PeerManager delegate connectivity-related operations to the Connectivity struct. Removed direct use of discovery_enabled and network global operations from PeerManager.
-
File Changes:
- connectivity.rs: Added implementation of the Connectivity struct.
- mod.rs: Updated to include the new Connectivity struct and network_globals_provider.
- network_behaviour.rs: Updated to use connectivity methods for checking connection limits.
- network_globals_provider.rs: New file introducing the NetworkGlobalsProvider trait and its implementation for Arc<NetworkGlobals<E>>.
Additional Info
The plan is to continue refactoring PeerManager and introducing new modules.
@diegomrsantos @AgeManning is this PR still required?
I'm not sure. I think we may have gone another way inside libp2p, right @diegomrsantos ?