Refactor read/write 1#316
Merged
Merged
Conversation
Contributor
turuslan
commented
Jul 8, 2025
- review and simplify usage of read/write by old code for Remove ambiguous argument #203
- noise, yamux, secio, mplex, echo
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This PR refactors asynchronous read/write logic across multiple protocols to use unified libp2p::read/libp2p::write functions and an IF_ERROR_CB_RETURN outcome macro, removing custom callback macros and simplifying buffer handling.
- Introduce
outcome_macro.hppwithIF_ERROR_CB_RETURNand replace custom error‐handling macros insecio,noise,insecure_rw,echo,yamux, andmplexmodules - Replace
write_return_size/read_return_sizecalls withlibp2p::write/libp2p::readand update callback signatures tooutcome::result<void> - Simplify per‐connection buffers (e.g.,
write_buffer_), remove obsolete context structs, and streamlinereadSome/writeSomeimplementations
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/security/secio/secio_connection.cpp | Use outcome_macro.hpp, replace manual macros, unify read/write logic |
| src/security/noise/noise_connection.cpp | Remove context struct, replace custom macros with IF_ERROR_CB_RETURN |
| src/security/noise/insecure_rw.cpp | Swap write_return_size/read_return_size for libp2p::read/write |
| src/protocol/echo/server_echo_session.cpp | Replace write_return_size with libp2p::write, adjust signatures |
| src/muxer/yamux/yamuxed_connection.cpp | Replace writeReturnSize with libp2p::write, update callback args |
| src/muxer/yamux/yamux_stream.cpp | Introduce FinallyReading, remove custom state, unify deferred calls |
| src/muxer/mplex/mplex_stream.cpp | Add ambigousSize, remove bytes field, use unified write calls |
| include/libp2p/common/outcome_macro.hpp | Add new outcome macros |
| include/libp2p/basic/cb.hpp | Define CbOutcomeVoid alias |
| include/libp2p/security/.../.hpp & muxer/.hpp | Update method signatures and remove obsolete types/fields |
kamilsa
approved these changes
Jul 8, 2025
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.