vacp2p / nim-libp2p

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

improvement: create a new gossipsub constructor #1078

Closed diegomrsantos closed 3 months ago

diegomrsantos commented 3 months ago

Before this PR, there were two ways of creating a GossipSubParam instance: using GossipSubParam.initor the GossipSubParams(propertyName: propertyValue) pattern. In the first case, there was no way to specify only a few values and use the rest as the default defined by nim-libp2p, as the init proc doesn't accept params. It was the same for the second case, the values not specified would be initialized as the nim default value for their types. This PR creates a new constructor with default values defined for all the params. The user can choose which ones to override or use the default value defined by the library.

codecov-commenter commented 3 months ago

Codecov Report

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

Project coverage is 84.81%. Comparing base (1a707e1) to head (52261f4).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1078/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/1078?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p) ```diff @@ Coverage Diff @@ ## unstable #1078 +/- ## ============================================ + Coverage 84.78% 84.81% +0.03% ============================================ Files 91 91 Lines 15420 15425 +5 ============================================ + Hits 13074 13083 +9 + Misses 2346 2342 -4 ``` | [Files](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1078?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/gossipsub.nim](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1078?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p#diff-bGlicDJwL3Byb3RvY29scy9wdWJzdWIvZ29zc2lwc3ViLm5pbQ==) | `86.46% <76.92%> (-0.08%)` | :arrow_down: | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/vacp2p/nim-libp2p/pull/1078/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vacp2p)