Skip to content

Refactor read/write 1#316

Merged
turuslan merged 9 commits into
masterfrom
refactor/read-write-1
Jul 8, 2025
Merged

Refactor read/write 1#316
turuslan merged 9 commits into
masterfrom
refactor/read-write-1

Conversation

@turuslan
Copy link
Copy Markdown
Contributor

@turuslan turuslan commented Jul 8, 2025

turuslan added 6 commits July 7, 2025 10:00
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>
@turuslan turuslan requested a review from kamilsa July 8, 2025 10:08
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
@kamilsa kamilsa requested a review from Copilot July 8, 2025 10:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.hpp with IF_ERROR_CB_RETURN and replace custom error‐handling macros in secio, noise, insecure_rw, echo, yamux, and mplex modules
  • Replace write_return_size/read_return_size calls with libp2p::write/libp2p::read and update callback signatures to outcome::result<void>
  • Simplify per‐connection buffers (e.g., write_buffer_), remove obsolete context structs, and streamline readSome/writeSome implementations

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

Comment thread src/security/secio/secio_connection.cpp
Comment thread src/security/secio/secio_connection.cpp
Comment thread src/security/noise/noise_connection.cpp
Comment thread src/security/noise/noise_connection.cpp
Comment thread include/libp2p/common/outcome_macro.hpp
Comment thread src/muxer/yamux/yamux_stream.cpp
Comment thread src/muxer/yamux/yamux_stream.cpp
turuslan added 2 commits July 8, 2025 19:42
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
Signed-off-by: turuslan <turuslan.devbox@gmail.com>
@turuslan turuslan merged commit 1a6942a into master Jul 8, 2025
3 of 4 checks passed
@turuslan turuslan deleted the refactor/read-write-1 branch July 8, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants