lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Refactor PeerManager to introduce Connectivity Module

Open diegomrsantos opened this issue 11 months ago • 3 comments

Issue Addressed

https://github.com/sigp/lighthouse/issues/6860

Proposed Changes

  1. 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.
  2. 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.
  3. 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.
  4. 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 avatar Jan 24 '25 12:01 diegomrsantos

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jan 24 '25 12:01 CLAassistant

@diegomrsantos @AgeManning is this PR still required?

jimmygchen avatar Nov 07 '25 04:11 jimmygchen

I'm not sure. I think we may have gone another way inside libp2p, right @diegomrsantos ?

AgeManning avatar Nov 10 '25 00:11 AgeManning