mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
feat: add Client trait for snap sync downloader client (#15449)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
24
crates/net/p2p/src/snap/client.rs
Normal file
24
crates/net/p2p/src/snap/client.rs
Normal 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;
|
||||
}
|
||||
2
crates/net/p2p/src/snap/mod.rs
Normal file
2
crates/net/p2p/src/snap/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
/// SNAP related traits.
|
||||
pub mod client;
|
||||
Reference in New Issue
Block a user