rust-ipfs icon indicating copy to clipboard operation
rust-ipfs copied to clipboard

Implement Connection Management

Open dariusc93 opened this issue 2 years ago • 2 comments

Currently, connection management is mostly connection limits, which is currently implemented into PeerBook using NetworkBehaviour (based on https://github.com/libp2p/rust-libp2p/pull/3386). This behaviour does support whitelisting peers (which is more of an "allow list") to bypass the limits, but this is basic (and would likely be in a separate behaviour)

Down the road, we would need a realistic connection manager that would close least useful connections upon reaching a specific limit set. This would close connections to peers that are not guarded or protected by a protocol or behaviour such gossipsub, kad, or even in cases like PeerBook, though may need to check to determine the best course on checking the peer in other behaviours outside of what we managed (eg if the peer is actively subscribed to a topic in gossip, or apart of routing in kad, used for a relay, exchanging data via bitswap, etc). A scoring system would likely need to be implemented in some way.

TODO:

  • [ ] Protect peers manually added to PeerBook
    • This is done already, but the peer should not be counted towards the connection limit, while the current implementation, it does count.
  • [ ] Make sure tagged peers dont count towards the connection limit
  • [ ] Tag peers used in specific protocols
    • [ ] Peers subscribed to the same topic in gossipsub, untagging when unsubscribed
    • [ ] Peers exchanging blocks with bitswap, untagging when exchanging of blocks are done or have timed out.
    • [ ] Peers used as a relay.
  • [ ] Automatically remove tagged peers that disconnected (though protected peers will remain in place)

dariusc93 avatar Mar 02 '23 16:03 dariusc93