Skip to content

eth/eth_session_channel.hpp

Namespaces

Name
eth

Classes

Name
class eth::IEthSessionChannel
Minimal session-facing seam used by ETH runner logic and tests.
class eth::RlpxEthSessionChannel
RlpxSession adapter implementing the minimal ETH session seam.

Source code

// Copyright 2026 Genius Ventures, Inc.
// SPDX-License-Identifier: MIT

#ifndef EVMRELAY_INCLUDE_ETH_ETH_SESSION_CHANNEL_HPP
#define EVMRELAY_INCLUDE_ETH_ETH_SESSION_CHANNEL_HPP

#include <rlpx/rlpx_session.hpp>

namespace eth {

class IEthSessionChannel
{
public:
    virtual ~IEthSessionChannel() = default;

    [[nodiscard]] virtual uint8_t negotiated_eth_version() const noexcept = 0;
    [[nodiscard]] virtual uint8_t negotiated_eth_offset() const noexcept = 0;
    [[nodiscard]] virtual const rlpx::PeerInfo& peer_info() const noexcept = 0;
    [[nodiscard]] virtual rlpx::VoidResult post_message(rlpx::framing::Message message) noexcept = 0;
    [[nodiscard]] virtual rlpx::Result<rlpx::framing::Message> receive_message(
        boost::asio::yield_context yield) noexcept = 0;
    [[nodiscard]] virtual rlpx::Result<rlpx::framing::Message> receive_message_with_timeout(
        std::chrono::steady_clock::duration timeout,
        boost::asio::yield_context          yield) noexcept = 0;
    virtual void set_eth_message_handler(rlpx::EthMessageHandler handler) noexcept = 0;
};

class RlpxEthSessionChannel final : public IEthSessionChannel
{
public:
    explicit RlpxEthSessionChannel(std::shared_ptr<rlpx::RlpxSession> session) noexcept;

    [[nodiscard]] uint8_t negotiated_eth_version() const noexcept override;
    [[nodiscard]] uint8_t negotiated_eth_offset() const noexcept override;
    [[nodiscard]] const rlpx::PeerInfo& peer_info() const noexcept override;
    [[nodiscard]] rlpx::VoidResult post_message(rlpx::framing::Message message) noexcept override;
    [[nodiscard]] rlpx::Result<rlpx::framing::Message> receive_message(
        boost::asio::yield_context yield) noexcept override;
    [[nodiscard]] rlpx::Result<rlpx::framing::Message> receive_message_with_timeout(
        std::chrono::steady_clock::duration timeout,
        boost::asio::yield_context          yield) noexcept override;
    void set_eth_message_handler(rlpx::EthMessageHandler handler) noexcept override;

private:
    std::shared_ptr<rlpx::RlpxSession> session_;
};

} // namespace eth


#endif // EVMRELAY_INCLUDE_ETH_ETH_SESSION_CHANNEL_HPP

Updated on 2026-06-05 at 17:22:19 -0700