docs(network): sync request handler structs with source (#20726)

This commit is contained in:
Satoshi Nakamoto
2026-01-05 11:56:07 +00:00
committed by GitHub
parent 8e9e595799
commit b51ce5c155

View File

@@ -285,9 +285,12 @@ The `FetchClient` struct, similar to `NetworkHandle`, can be shared across threa
[File: crates/net/network/src/fetch/client.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/fetch/client.rs) [File: crates/net/network/src/fetch/client.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/fetch/client.rs)
```rust,ignore ```rust,ignore
pub struct FetchClient<N: NetworkPrimitives = EthNetworkPrimitives> { pub struct FetchClient<N: NetworkPrimitives = EthNetworkPrimitives> {
request_tx: UnboundedSender<DownloadRequest<N>>, /// Sender half of the request channel.
peers_handle: PeersHandle, pub(crate) request_tx: UnboundedSender<DownloadRequest<N>>,
num_active_peers: Arc<AtomicUsize> /// The handle to the peers
pub(crate) peers_handle: PeersHandle,
/// Number of active peer sessions the node's currently handling.
pub(crate) num_active_peers: Arc<AtomicUsize>,
} }
``` ```
@@ -299,23 +302,23 @@ The fields `request_tx` and `peers_handle` are cloned off of the `StateFetcher`
[File: crates/net/network/src/fetch/mod.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/fetch/mod.rs) [File: crates/net/network/src/fetch/mod.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/fetch/mod.rs)
```rust,ignore ```rust,ignore
pub struct StateFetcher { pub struct StateFetcher<N: NetworkPrimitives = EthNetworkPrimitives> {
/// Currently active [`GetBlockHeaders`] requests /// Currently active [`GetBlockHeaders`] requests
inflight_headers_requests: inflight_headers_requests: HashMap<PeerId, InflightHeadersRequest<N::BlockHeader>>,
HashMap<PeerId, Request<HeadersRequest, PeerRequestResult<Vec<Header>>>>,
/// Currently active [`GetBlockBodies`] requests /// Currently active [`GetBlockBodies`] requests
inflight_bodies_requests: inflight_bodies_requests: HashMap<PeerId, InflightBodiesRequest<N::BlockBody>>,
HashMap<PeerId, Request<Vec<B256>, PeerRequestResult<Vec<BlockBody>>>>,
/// The list of _available_ peers for requests. /// The list of _available_ peers for requests.
peers: HashMap<PeerId, Peer>, peers: HashMap<PeerId, Peer>,
/// The handle to the peers manager /// The handle to the peers manager
peers_handle: PeersHandle, peers_handle: PeersHandle,
/// Number of active peer sessions the node's currently handling.
num_active_peers: Arc<AtomicUsize>,
/// Requests queued for processing /// Requests queued for processing
queued_requests: VecDeque<DownloadRequest>, queued_requests: VecDeque<DownloadRequest<N>>,
/// Receiver for new incoming download requests /// Receiver for new incoming download requests
download_requests_rx: UnboundedReceiverStream<DownloadRequest>, download_requests_rx: UnboundedReceiverStream<DownloadRequest<N>>,
/// Sender for download requests, used to detach a [`FetchClient`] /// Sender for download requests, used to detach a [`FetchClient`]
download_requests_tx: UnboundedSender<DownloadRequest>, download_requests_tx: UnboundedSender<DownloadRequest<N>>,
} }
``` ```
@@ -323,24 +326,26 @@ This struct itself is nested deeply within the `NetworkManager`: its `Swarm` str
[File: crates/net/network/src/state.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/state.rs) [File: crates/net/network/src/state.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/state.rs)
```rust,ignore ```rust,ignore
pub struct NetworkState<C> { pub struct NetworkState<N: NetworkPrimitives = EthNetworkPrimitives> {
/// All active peers and their state. /// All active peers and their state.
active_peers: HashMap<PeerId, ActivePeer>, active_peers: HashMap<PeerId, ActivePeer<N>>,
/// Manages connections to peers. /// Manages connections to peers.
peers_manager: PeersManager, peers_manager: PeersManager,
/// Buffered messages until polled. /// Buffered messages until polled.
queued_messages: VecDeque<StateAction>, queued_messages: VecDeque<StateAction<N>>,
/// The client type that can interact with the chain. /// The client type that can interact with the chain.
client: Arc<C>, ///
/// This type is used to fetch the block number after we established a session and received the
/// [`UnifiedStatus`] block hash.
client: BlockNumReader,
/// Network discovery. /// Network discovery.
discovery: Discovery, discovery: Discovery,
/// The genesis hash of the network we're on
genesis_hash: B256,
/// The type that handles requests. /// The type that handles requests.
/// ///
/// The fetcher streams ``RLPx`` related requests on a per-peer basis to this type. This type will /// The fetcher streams `RLPx` related requests on a per-peer basis to this type. This type
/// then queue in the request and notify the fetcher once the result has been received. /// will then queue in the request and notify the fetcher once the result has been
state_fetcher: StateFetcher, /// received.
state_fetcher: StateFetcher<N>,
} }
``` ```
@@ -483,14 +488,16 @@ Similar to the network management task, it's implemented as an endless future, b
[File: crates/net/network/src/eth_requests.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/eth_requests.rs) [File: crates/net/network/src/eth_requests.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/eth_requests.rs)
```rust,ignore ```rust,ignore
pub struct EthRequestHandler<C> { pub struct EthRequestHandler<C, N: NetworkPrimitives = EthNetworkPrimitives> {
/// The client type that can interact with the chain. /// The client type that can interact with the chain.
client: Arc<C>, client: C,
/// Used for reporting peers. /// Used for reporting peers.
#[expect(dead_code)] #[expect(dead_code)]
peers: PeersHandle, peers: PeersHandle,
/// Incoming request from the [NetworkManager](crate::NetworkManager). /// Incoming request from the [`NetworkManager`](crate::NetworkManager).
incoming_requests: UnboundedReceiverStream<IncomingEthRequest>, incoming_requests: ReceiverStream<IncomingEthRequest<N>>,
/// Metrics for the eth request handler.
metrics: EthRequestHandlerMetrics,
} }
``` ```
@@ -988,16 +995,16 @@ After `TransactionsCommand`s, it's time to take care of transactions-related req
[File: crates/net/network/src/transactions.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/transactions.rs) [File: crates/net/network/src/transactions.rs](https://github.com/paradigmxyz/reth/blob/1563506aea09049a85e5cc72c2894f3f7a371581/crates/net/network/src/transactions.rs)
```rust,ignore ```rust,ignore
pub enum NetworkTransactionEvent { pub enum NetworkTransactionEvent<N: NetworkPrimitives = EthNetworkPrimitives> {
/// Received list of transactions from the given peer. /// Received list of transactions from the given peer.
IncomingTransactions { peer_id: PeerId, msg: Transactions }, IncomingTransactions { peer_id: PeerId, msg: Transactions<N::BroadcastedTransaction> },
/// Received list of transactions hashes to the given peer. /// Received list of transactions hashes to the given peer.
IncomingPooledTransactionHashes { peer_id: PeerId, msg: NewPooledTransactionHashes }, IncomingPooledTransactionHashes { peer_id: PeerId, msg: NewPooledTransactionHashes },
/// Incoming `GetPooledTransactions` request from a peer. /// Incoming `GetPooledTransactions` request from a peer.
GetPooledTransactions { GetPooledTransactions {
peer_id: PeerId, peer_id: PeerId,
request: GetPooledTransactions, request: GetPooledTransactions,
response: oneshot::Sender<RequestResult<PooledTransactions>>, response: oneshot::Sender<RequestResult<PooledTransactions<N::PooledTransaction>>>,
}, },
} }
``` ```