vacp2p / nim-libp2p

libp2p implementation in Nim
https://vacp2p.github.io/nim-libp2p/docs/
MIT License
242 stars 52 forks source link

feat: add max number of elements to non-prio queue #1077

Closed diegomrsantos closed 3 months ago

diegomrsantos commented 3 months ago

This PR adds a default limit to the number of elements in the non-priority queue. When this limit has been reached, the peer will be disconnected. The default value is 1024 but can also be configured through a new GossipSub param maxNumElementsInNonPriorityQueue.

diegomrsantos commented 3 months ago

@arnetheduck how about replacing https://github.com/vacp2p/nim-libp2p/pull/1077/files#diff-abbf987f19a24c9940cd01bde79a1b1e0819f1c3b6d7ba2efa04ad680d022c78R182-R186 by unsubscribePeer?

arnetheduck commented 3 months ago

@arnetheduck how about replacing https://github.com/vacp2p/nim-libp2p/pull/1077/files#diff-abbf987f19a24c9940cd01bde79a1b1e0819f1c3b6d7ba2efa04ad680d022c78R182-R186 by unsubscribePeer?

let's start with peer disconnection (to maintain current behavior) - when we reach a stable point with that working, we can consider other strategies (so that we can get a release out).

codecov-commenter commented 3 months ago

Codecov Report

Attention: Patch coverage is 71.42857% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 84.79%. Comparing base (458b088) to head (067b0f5).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1077/graphs/tree.svg?width=650&height=150&src=pr&token=M88zHaQffJ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p)](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1077?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p) ```diff @@ Coverage Diff @@ ## unstable #1077 +/- ## ============================================ - Coverage 84.83% 84.79% -0.04% ============================================ Files 91 91 Lines 15405 15420 +15 ============================================ + Hits 13069 13076 +7 - Misses 2336 2344 +8 ``` | [Files](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1077?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p) | Coverage Δ | | |---|---|---| | [libp2p/protocols/pubsub/pubsub.nim](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1077?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p#diff-bGlicDJwL3Byb3RvY29scy9wdWJzdWIvcHVic3ViLm5pbQ==) | `84.29% <100.00%> (ø)` | | | [libp2p/protocols/pubsub/gossipsub.nim](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1077?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p#diff-bGlicDJwL3Byb3RvY29scy9wdWJzdWIvZ29zc2lwc3ViLm5pbQ==) | `86.54% <66.66%> (-0.18%)` | :arrow_down: | | [libp2p/protocols/pubsub/pubsubpeer.nim](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1077?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p#diff-bGlicDJwL3Byb3RvY29scy9wdWJzdWIvcHVic3VicGVlci5uaW0=) | `86.14% <70.96%> (-2.10%)` | :arrow_down: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1077/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p)