reth_network_p2p/snap/
client.rs

1use crate::{download::DownloadClient, error::PeerRequestResult, priority::Priority};
2use futures::Future;
3use reth_eth_wire_types::snap::{
4    AccountRangeMessage, GetAccountRangeMessage, GetByteCodesMessage, GetStorageRangesMessage,
5    GetTrieNodesMessage,
6};
7
8/// The snap sync downloader client
9#[auto_impl::auto_impl(&, Arc, Box)]
10pub trait SnapClient: DownloadClient {
11    /// The output future type for account range requests
12    type Output: Future<Output = PeerRequestResult<AccountRangeMessage>> + Send + Sync + Unpin;
13
14    /// Sends the account range request to the p2p network and returns the account range
15    /// response received from a peer.
16    fn get_account_range(&self, request: GetAccountRangeMessage) -> Self::Output {
17        self.get_account_range_with_priority(request, Priority::Normal)
18    }
19
20    /// Sends the account range request to the p2p network with priority set and returns
21    /// the account range response received from a peer.
22    fn get_account_range_with_priority(
23        &self,
24        request: GetAccountRangeMessage,
25        priority: Priority,
26    ) -> Self::Output;
27
28    /// Sends the storage ranges request to the p2p network and returns the storage ranges
29    /// response received from a peer.
30    fn get_storage_ranges(&self, request: GetStorageRangesMessage) -> Self::Output;
31
32    /// Sends the storage ranges request to the p2p network with priority set and returns
33    /// the storage ranges response received from a peer.
34    fn get_storage_ranges_with_priority(
35        &self,
36        request: GetStorageRangesMessage,
37        priority: Priority,
38    ) -> Self::Output;
39
40    /// Sends the byte codes request to the p2p network and returns the byte codes
41    /// response received from a peer.
42    fn get_byte_codes(&self, request: GetByteCodesMessage) -> Self::Output;
43
44    /// Sends the byte codes request to the p2p network with priority set and returns
45    /// the byte codes response received from a peer.
46    fn get_byte_codes_with_priority(
47        &self,
48        request: GetByteCodesMessage,
49        priority: Priority,
50    ) -> Self::Output;
51
52    /// Sends the trie nodes request to the p2p network and returns the trie nodes
53    /// response received from a peer.
54    fn get_trie_nodes(&self, request: GetTrieNodesMessage) -> Self::Output;
55
56    /// Sends the trie nodes request to the p2p network with priority set and returns
57    /// the trie nodes response received from a peer.
58    fn get_trie_nodes_with_priority(
59        &self,
60        request: GetTrieNodesMessage,
61        priority: Priority,
62    ) -> Self::Output;
63}