mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 09:08:05 -05:00
docs: add outgoing request diagram (#630)
This commit is contained in:
@@ -15,6 +15,43 @@ use reth_primitives::{PeerId, WithPeerId, H256};
|
||||
use tokio::sync::{mpsc::UnboundedSender, oneshot};
|
||||
|
||||
/// Front-end API for fetching data from the network.
|
||||
///
|
||||
/// Following diagram illustrates how a request, See [`HeadersClient::get_headers`] and
|
||||
/// [`BodiesClient::get_block_bodies`] is handled internally.
|
||||
#[cfg_attr(doc, aquamarine::aquamarine)]
|
||||
/// ```mermaid
|
||||
/// sequenceDiagram
|
||||
// participant Client as FetchClient
|
||||
// participant Fetcher as StateFetcher
|
||||
// participant State as NetworkState
|
||||
// participant Session as Active Peer Session
|
||||
// participant Peers as PeerManager
|
||||
// loop Send Request, retry if retriable and remaining retries
|
||||
// Client->>Fetcher: DownloadRequest{GetHeaders, GetBodies}
|
||||
// Note over Client,Fetcher: Request and oneshot Sender sent via `request_tx` channel
|
||||
// loop Process buffered requests
|
||||
// State->>Fetcher: poll action
|
||||
// Fetcher->>Fetcher: Select Available Peer
|
||||
// Note over Fetcher: Peer is available if it's currently idle, no inflight requests
|
||||
// Fetcher->>State: FetchAction::BlockDownloadRequest
|
||||
// State->>Session: Delegate Request
|
||||
// Note over State,Session: Request and oneshot Sender sent via `to_session_tx` channel
|
||||
// end
|
||||
// Session->>Session: Send Request to remote
|
||||
// Session->>Session: Enforce Request timeout
|
||||
// Session-->>State: Send Response Result via channel
|
||||
// State->>Fetcher: Delegate Response
|
||||
// Fetcher-->>Client: Send Response via channel
|
||||
// opt Bad Response
|
||||
// Client->>Peers: Penalize Peer
|
||||
// end
|
||||
// Peers->>Peers: Apply Reputation Change
|
||||
// opt reputation dropped below threshold
|
||||
// Peers->>State: Disconnect Session
|
||||
// State->>Session: Delegate Disconnect
|
||||
// end
|
||||
// end
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct FetchClient {
|
||||
/// Sender half of the request channel.
|
||||
|
||||
Reference in New Issue
Block a user