Skip to content

Conversation

@turuslan
Copy link
Contributor

  • MessageReadWriter returns void, because it writes message completely
  • remove readReturnSize/writeReturnSize wrappers, use read/write which return void, because they read/write message completely

turuslan added 4 commits July 15, 2025 07:50
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 15, 2025 06:39
@kamilsa kamilsa requested a review from Copilot July 15, 2025 08:24
Copy link

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

Refactors the codebase to remove the readReturnSize/writeReturnSize wrappers and switch all calls to the new read/write APIs that return void, simplifying the message read/write flow.

  • Updated all include statements to use <libp2p/basic/read.hpp> and <libp2p/basic/write.hpp> where wrappers were removed.
  • Replaced every readReturnSize/writeReturnSize invocation with libp2p::read/libp2p::write and adjusted callbacks to handle outcome::result<void>.
  • Deleted the now-obsolete read_return_size.hpp and write_return_size.hpp headers and updated related interface signatures.

Reviewed Changes

Copilot reviewed 58 out of 58 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/testutil/expect_write.hpp Updated write-expectation macro to use new write API
test/testutil/expect_read.hpp Updated read-expectation macro to use new read API
test/mock/libp2p/connection/stream_mock.hpp Removed old wrapper include
test/mock/libp2p/connection/layer_connection_mock.hpp Removed old wrapper include and reformatted class declaration
test/mock/libp2p/connection/capable_connection_mock.hpp Switched to direct readSome/writeSome forwarding
test/libp2p/transport/tcp/tcp_integration_test.cpp Replaced wrapper calls with read/write
test/libp2p/protocol/identify_delta_test.cpp Cleaned up unused lambda and updated write call
test/libp2p/muxer/muxers_and_streams_test.cpp Switched wrapper calls to read/write
test/libp2p/connection/security_conn/plaintext_connection_test.cpp Updated to new read/write API
test/libp2p/connection/loopback_stream/loopback_stream_test.cpp Switched wrapper calls to read/write
test/libp2p/basic/message_read_writer_test.cpp Updated callback to handle void result
test/acceptance/p2p/muxer.cpp Replaced wrapper calls and adjusted integration callbacks
test/acceptance/p2p/host/protocol/client_test_session.cpp Updated to new read/write API and macros
src/transport/tcp/tcp_connection.cpp Removed obsolete wrapper include
src/transport/quic/stream.cpp Removed obsolete wrapper include and reformatted lambda
src/transport/quic/connection.cpp Removed obsolete wrapper include and reformatted lambda
src/security/tls/tls_connection.cpp Removed obsolete wrapper include
src/security/secio/secio_connection.cpp Switched to new read/write include
src/security/secio/secio.cpp Updated handshake reads/writes to read/write
src/security/plaintext/plaintext_connection.cpp Removed obsolete wrapper include
src/security/noise/noise_connection.cpp Updated to new write callback signature
src/security/noise/insecure_rw.cpp Switched to libp2p::read/libp2p::write and new callback
src/security/noise/handshake.cpp Removed wrapper logic, updated macros and callbacks
src/protocol_muxer/multiselect/simple_stream_negotiate.cpp Replaced wrapper calls with read/write
src/protocol_muxer/multiselect/multiselect_instance.cpp Switched wrapper callbacks to void result type
src/protocol/ping/ping_server_session.cpp Replaced wrapper calls with read/write
src/protocol/ping/ping_client_session.cpp Updated write/read callbacks to void result type
src/protocol/identify/identify_msg_processor.cpp Switched callback signature on write
src/protocol/gossip/impl/stream.hpp Updated method declarations to use void result type
src/protocol/gossip/impl/stream.cpp Replaced wrapper calls with read/write and updated callbacks
src/protocol/echo/server_echo_session.cpp Reformatted readSome call
src/protocol/echo/client_echo_session.cpp Switched to write API
src/muxer/yamux/yamuxed_connection.cpp Reformatted method signatures
src/muxer/yamux/yamux_stream.cpp Removed obsolete wrapper include
src/muxer/mplex/mplexed_connection.cpp Switched wrapper to direct write and updated callback
src/muxer/mplex/mplex_stream.cpp Replaced wrapper calls with writeSome
src/muxer/mplex/mplex_frame.cpp Updated read callback and error handling macro
src/layer/websocket/ws_connection.cpp Removed obsolete wrapper include and reformatted lambda
src/layer/websocket/ssl_connection.cpp Removed obsolete wrapper include
src/connection/loopback_stream.cpp Removed obsolete wrapper include and updated callbacks
src/basic/varint_reader.cpp Switched to new read API and adjusted recursion callback
src/basic/message_read_writer_uvarint.cpp Replaced wrapper calls with read/write and new callback
src/basic/message_read_writer_bigendian.cpp Switched wrapper calls to read/write and updated callback
include/libp2p/security/noise/insecure_rw.hpp Updated interface to new callback type
include/libp2p/security/noise/handshake.hpp Updated handshake send API to new callback type
include/libp2p/protocol_muxer/multiselect/multiselect_instance.hpp Updated API to use void result callbacks
include/libp2p/protocol/ping/ping_client_session.hpp Switched callback signatures for write/read
include/libp2p/protocol/identify/identify_msg_processor.hpp Updated callback signature on identifySent
include/libp2p/network/impl/listener_manager_impl.hpp Reformatted container declaration
include/libp2p/muxer/mplex/mplexed_connection.hpp Updated write callback signature and include cb.hpp
include/libp2p/connection/as_asio_read_write.hpp Reformatted single-line calls
include/libp2p/basic/protobuf_message_read_writer.hpp Updated write callback to CbOutcomeVoid
include/libp2p/basic/message_read_writer_uvarint.hpp Switched write callback type to CbOutcomeVoid
include/libp2p/basic/message_read_writer_bigendian.hpp Switched write callback type to CbOutcomeVoid
include/libp2p/basic/message_read_writer.hpp Added cb.hpp include and switched base callback to void type
example/02-kademlia/rendezvous_chat.cpp Replaced wrapper call with write and updated output formatting
Comments suppressed due to low confidence (2)

include/libp2p/security/noise/handshake.hpp:49

  • Ensure that CbOutcomeVoid is defined in this header (e.g., by including <libp2p/basic/cb.hpp> or another header that declares it), otherwise the new callback type will be unrecognized at compile time.
    void sendHandshakeMessage(BytesIn payload, CbOutcomeVoid cb);

test/acceptance/p2p/muxer.cpp:130

  • After switching to libp2p::read, use outcome::result<void> for the readSome callback instead of outcome::result<size_t>, since the new API no longer returns the byte count.
    stream->readSome(*buf, [buf, stream, this](outcome::result<size_t> rread) {

@turuslan turuslan merged commit fd17562 into master Jul 15, 2025
3 of 4 checks passed
@turuslan turuslan deleted the refactor/write-return-size branch July 15, 2025 18:15
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