diff --git a/docs/crates/network.md b/docs/crates/network.md index e2ffc55df2..c69ee8c02b 100644 --- a/docs/crates/network.md +++ b/docs/crates/network.md @@ -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) ```rust,ignore pub struct FetchClient { - request_tx: UnboundedSender>, - peers_handle: PeersHandle, - num_active_peers: Arc + /// Sender half of the request channel. + pub(crate) request_tx: UnboundedSender>, + /// 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, } ``` @@ -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) ```rust,ignore -pub struct StateFetcher { +pub struct StateFetcher { /// Currently active [`GetBlockHeaders`] requests - inflight_headers_requests: - HashMap>>>, + inflight_headers_requests: HashMap>, /// Currently active [`GetBlockBodies`] requests - inflight_bodies_requests: - HashMap, PeerRequestResult>>>, + inflight_bodies_requests: HashMap>, /// The list of _available_ peers for requests. peers: HashMap, /// The handle to the peers manager peers_handle: PeersHandle, + /// Number of active peer sessions the node's currently handling. + num_active_peers: Arc, /// Requests queued for processing - queued_requests: VecDeque, + queued_requests: VecDeque>, /// Receiver for new incoming download requests - download_requests_rx: UnboundedReceiverStream, + download_requests_rx: UnboundedReceiverStream>, /// Sender for download requests, used to detach a [`FetchClient`] - download_requests_tx: UnboundedSender, + download_requests_tx: UnboundedSender>, } ``` @@ -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) ```rust,ignore -pub struct NetworkState { +pub struct NetworkState { /// All active peers and their state. - active_peers: HashMap, + active_peers: HashMap>, /// Manages connections to peers. peers_manager: PeersManager, /// Buffered messages until polled. - queued_messages: VecDeque, + queued_messages: VecDeque>, /// The client type that can interact with the chain. - client: Arc, + /// + /// This type is used to fetch the block number after we established a session and received the + /// [`UnifiedStatus`] block hash. + client: BlockNumReader, /// Network discovery. discovery: Discovery, - /// The genesis hash of the network we're on - genesis_hash: B256, /// The type that handles requests. /// - /// The fetcher streams ``RLPx`` related requests on a per-peer basis to this type. This type will - /// then queue in the request and notify the fetcher once the result has been received. - state_fetcher: StateFetcher, + /// The fetcher streams `RLPx` related requests on a per-peer basis to this type. This type + /// will then queue in the request and notify the fetcher once the result has been + /// received. + state_fetcher: StateFetcher, } ``` @@ -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) ```rust,ignore -pub struct EthRequestHandler { +pub struct EthRequestHandler { /// The client type that can interact with the chain. - client: Arc, + client: C, /// Used for reporting peers. #[expect(dead_code)] peers: PeersHandle, - /// Incoming request from the [NetworkManager](crate::NetworkManager). - incoming_requests: UnboundedReceiverStream, + /// Incoming request from the [`NetworkManager`](crate::NetworkManager). + incoming_requests: ReceiverStream>, + /// 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) ```rust,ignore -pub enum NetworkTransactionEvent { +pub enum NetworkTransactionEvent { /// Received list of transactions from the given peer. - IncomingTransactions { peer_id: PeerId, msg: Transactions }, + IncomingTransactions { peer_id: PeerId, msg: Transactions }, /// Received list of transactions hashes to the given peer. IncomingPooledTransactionHashes { peer_id: PeerId, msg: NewPooledTransactionHashes }, /// Incoming `GetPooledTransactions` request from a peer. GetPooledTransactions { peer_id: PeerId, request: GetPooledTransactions, - response: oneshot::Sender>, + response: oneshot::Sender>>, }, } ```