-
Notifications
You must be signed in to change notification settings - Fork 118
Refactor write return size #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
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/writeReturnSizeinvocation withlibp2p::read/libp2p::writeand adjusted callbacks to handleoutcome::result<void>. - Deleted the now-obsolete
read_return_size.hppandwrite_return_size.hppheaders 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
CbOutcomeVoidis 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, useoutcome::result<void>for thereadSomecallback instead ofoutcome::result<size_t>, since the new API no longer returns the byte count.
stream->readSome(*buf, [buf, stream, this](outcome::result<size_t> rread) {
MessageReadWriterreturns void, because it writes message completelyreadReturnSize/writeReturnSizewrappers, useread/writewhich return void, because they read/write message completely