feat: add Client trait for snap sync downloader client (#15449)

This commit is contained in:
Steven
2025-04-02 03:33:03 -06:00
committed by GitHub
parent 40015a821b
commit 69df27e9b5
4 changed files with 30 additions and 1 deletions

View File

@@ -47,7 +47,7 @@ pub use capability::*;
pub mod primitives;
pub use primitives::*;
mod snap;
pub mod snap;
pub use snap::*;
/// re-export for convenience

View File

@@ -41,6 +41,9 @@ pub mod priority;
/// Syncing related traits.
pub mod sync;
/// Snap related traits.
pub mod snap;
/// Common test helpers for mocking out Consensus, Downloaders and Header Clients.
#[cfg(any(test, feature = "test-utils"))]
pub mod test_utils;

View File

@@ -0,0 +1,24 @@
use crate::{download::DownloadClient, error::PeerRequestResult, priority::Priority};
use futures::Future;
use reth_eth_wire_types::snap::{AccountRangeMessage, GetAccountRangeMessage};
/// The snap sync downloader client
#[auto_impl::auto_impl(&, Arc, Box)]
pub trait SnapClient: DownloadClient {
/// The output future type for account range requests
type Output: Future<Output = PeerRequestResult<AccountRangeMessage>> + Send + Sync + Unpin;
/// Sends the account range request to the p2p network and returns the account range
/// response received from a peer.
fn get_account_range(&self, request: GetAccountRangeMessage) -> Self::Output {
self.get_account_range_with_priority(request, Priority::Normal)
}
/// Sends the account range request to the p2p network with priority set and returns
/// the account range response received from a peer.
fn get_account_range_with_priority(
&self,
request: GetAccountRangeMessage,
priority: Priority,
) -> Self::Output;
}

View File

@@ -0,0 +1,2 @@
/// SNAP related traits.
pub mod client;