diff --git a/crates/net/eth-wire-types/src/lib.rs b/crates/net/eth-wire-types/src/lib.rs index 9bbbc2359d..2fbe81ecd0 100644 --- a/crates/net/eth-wire-types/src/lib.rs +++ b/crates/net/eth-wire-types/src/lib.rs @@ -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 diff --git a/crates/net/p2p/src/lib.rs b/crates/net/p2p/src/lib.rs index 0c5e1e3264..b3c0b30508 100644 --- a/crates/net/p2p/src/lib.rs +++ b/crates/net/p2p/src/lib.rs @@ -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; diff --git a/crates/net/p2p/src/snap/client.rs b/crates/net/p2p/src/snap/client.rs new file mode 100644 index 0000000000..7f08da31e2 --- /dev/null +++ b/crates/net/p2p/src/snap/client.rs @@ -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> + 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; +} diff --git a/crates/net/p2p/src/snap/mod.rs b/crates/net/p2p/src/snap/mod.rs new file mode 100644 index 0000000000..7dadcad160 --- /dev/null +++ b/crates/net/p2p/src/snap/mod.rs @@ -0,0 +1,2 @@ +/// SNAP related traits. +pub mod client;