[mplex, yamux] Streamline configuration API. #1822
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proposal for streamlining the configuration APIs of
libp2p-mplex
andlibp2p-yamux
, i.e. to close #1531. I made the following choices:configuration.
yamux::Config
toYamuxConfig
for consistency with the majority of other protocols, e.g.MplexConfig
,PingConfig
,KademliaConfig
, etc.yamux
APIs withinlibp2p-yamux
. This is a trade-off. It allows to fully control the libp2p API and streamline it with other muxer APIs, consciously choosing e.g. which configuration options to make configurable in libp2p and which to fix to certain values (e.g. we currently always fixread_after_close
which is not actually configurable for libp2p). It also means that new incompatible version bumps of yamux need not necessarily require analogous bumps forlibp2p-yamux
, as noyamux
types are exposed. The cost is naturally some more duplication of configuration options in the API, as well as the need to updatelibp2p-yamux
ifyamux
introduces new configuration options thatlibp2p-yamux
wants to expose as well. Overall I think fully hidingyamux
from the API, i.e. making it an implementation detail, is preferable.