rlpx::RlpxSession¶
RLPx session managing encrypted P2P communication.
#include <rlpx_session.hpp>
Inherits from std::enable_shared_from_this< RlpxSession >
Public Classes¶
| Name | |
|---|---|
| class | MessageChannel |
Public Functions¶
| Name | |
|---|---|
| Result< std::shared_ptr< RlpxSession > > | connect(const SessionConnectParams & params, boost::asio::yield_context yield) Factory for outbound connections. |
| Result< std::shared_ptr< RlpxSession > > | connect(const SessionConnectParams & params, boost::asio::yield_context yield, DisconnectReason * pre_hello_disconnect_reason) Factory for outbound connections, returning a peer disconnect reason if the peer sends Disconnect before HELLO. |
| Result< std::shared_ptr< RlpxSession > > | accept(const SessionAcceptParams & params, boost::asio::yield_context yield) Factory for inbound connections. |
| uint8_t | negotiate_eth_version_for_test(const std::vector< protocol::Capability > & capabilities) Test helper that selects the highest supported ETH version from capabilities. |
| uint8_t | negotiate_eth_offset_for_test(const std::vector< protocol::Capability > & capabilities) Test helper that computes the negotiated ETH wire offset from capabilities. |
| std::optional< uint8_t > | normalize_eth_message_id_for_test(uint8_t wire_message_id, uint8_t negotiated_eth_offset) Test helper that normalizes a wire-level ETH message id using the negotiated offset. |
| ~RlpxSession() | |
| RlpxSession(const RlpxSession & ) =delete | |
| RlpxSession & | operator=(const RlpxSession & ) =delete |
| RlpxSession(RlpxSession && other) | |
| RlpxSession & | operator=(RlpxSession && other) |
| VoidResult | post_message(framing::Message message) Send message (takes ownership via move). |
| Result< framing::Message > | receive_message_with_timeout(std::chrono::steady_clock::duration timeout, boost::asio::yield_context yield) Receive message with timeout during protocol startup handshakes. |
| Result< framing::Message > | receive_message(boost::asio::yield_context yield) Receive message (stackful coroutine pull model). |
| VoidResult | disconnect(DisconnectReason reason) Graceful disconnect (sync, callable from callbacks). |
| VoidResult | disconnect(DisconnectReason reason, boost::asio::yield_context yield) Graceful disconnect (coroutine overload). |
| void | set_hello_handler(HelloHandler handler) |
| void | set_disconnect_handler(DisconnectHandler handler) |
| void | set_ping_handler(PingHandler handler) |
| void | set_pong_handler(PongHandler handler) |
| void | set_generic_handler(MessageHandler handler) |
| void | set_eth_message_handler(EthMessageHandler handler) |
| SessionState | state() const |
| bool | is_active() const |
| const PeerInfo & | peer_info() const |
| uint8_t | negotiated_eth_version() const Return the negotiated ETH subprotocol version from HELLO capability matching. |
| uint8_t | negotiated_eth_offset() const Return the negotiated ETH subprotocol message-id base offset. |
| const auth::FrameSecrets & | cipher_secrets() const |
Public Functions Documentation¶
function connect¶
static Result< std::shared_ptr< RlpxSession > > connect(
const SessionConnectParams & params,
boost::asio::yield_context yield
)
Factory for outbound connections.
Parameters:
- params Session connection parameters.
- yield Boost.Asio stackful coroutine context.
Return: Constructed session on success, SessionError on failure.
function connect¶
static Result< std::shared_ptr< RlpxSession > > connect(
const SessionConnectParams & params,
boost::asio::yield_context yield,
DisconnectReason * pre_hello_disconnect_reason
)
Factory for outbound connections, returning a peer disconnect reason if the peer sends Disconnect before HELLO.
function accept¶
static Result< std::shared_ptr< RlpxSession > > accept(
const SessionAcceptParams & params,
boost::asio::yield_context yield
)
Factory for inbound connections.
Parameters:
- params Session accept parameters.
- yield Boost.Asio stackful coroutine context.
Return: Constructed session on success, SessionError on failure.
function negotiate_eth_version_for_test¶
static uint8_t negotiate_eth_version_for_test(
const std::vector< protocol::Capability > & capabilities
)
Test helper that selects the highest supported ETH version from capabilities.
Parameters:
- capabilities Peer HELLO capabilities.
Return: Highest supported ETH version, or 0 if none.
function negotiate_eth_offset_for_test¶
static uint8_t negotiate_eth_offset_for_test(
const std::vector< protocol::Capability > & capabilities
)
Test helper that computes the negotiated ETH wire offset from capabilities.
Parameters:
- capabilities Peer HELLO capabilities.
Return: ETH wire offset, or 0 if no ETH capability was negotiated.
function normalize_eth_message_id_for_test¶
static std::optional< uint8_t > normalize_eth_message_id_for_test(
uint8_t wire_message_id,
uint8_t negotiated_eth_offset
)
Test helper that normalizes a wire-level ETH message id using the negotiated offset.
Parameters:
- wire_message_id Wire-level RLPx message id.
- negotiated_eth_offset Negotiated ETH subprotocol offset.
Return: ETH-local message id when the wire id belongs to ETH; std::nullopt otherwise.
function ~RlpxSession¶
function RlpxSession¶
function operator=¶
function RlpxSession¶
function operator=¶
function post_message¶
Send message (takes ownership via move).
function receive_message_with_timeout¶
Result< framing::Message > receive_message_with_timeout(
std::chrono::steady_clock::duration timeout,
boost::asio::yield_context yield
)
Receive message with timeout during protocol startup handshakes.
Parameters:
- timeout Maximum time to wait for one inbound message.
- yield Boost.Asio stackful coroutine context.
Return: Next message on success, SessionError on timeout or transport failure.
function receive_message¶
Receive message (stackful coroutine pull model).
Parameters:
- yield Boost.Asio stackful coroutine context.
Return: Next message on success, SessionError on failure.
function disconnect¶
Graceful disconnect (sync, callable from callbacks).
Parameters:
- reason Disconnect reason code.
function disconnect¶
Graceful disconnect (coroutine overload).
Parameters:
- reason Disconnect reason code.
- yield Boost.Asio stackful coroutine context.
function set_hello_handler¶
function set_disconnect_handler¶
function set_ping_handler¶
function set_pong_handler¶
function set_generic_handler¶
function set_eth_message_handler¶
function state¶
function is_active¶
function peer_info¶
function negotiated_eth_version¶
Return the negotiated ETH subprotocol version from HELLO capability matching.
Return: 66, 67, 68, or 69 when a common ETH capability was negotiated; 0 otherwise.
function negotiated_eth_offset¶
Return the negotiated ETH subprotocol message-id base offset.
Return: Wire-level ETH base offset when a common ETH capability was negotiated; 0 otherwise.
function cipher_secrets¶
Updated on 2026-06-05 at 17:22:18 -0700