reth_network_p2p/snap/
client.rs1use crate::{download::DownloadClient, error::PeerRequestResult, priority::Priority};
2use futures::Future;
3use reth_eth_wire_types::snap::{
4 AccountRangeMessage, ByteCodesMessage, GetAccountRangeMessage, GetByteCodesMessage,
5 GetStorageRangesMessage, GetTrieNodesMessage, StorageRangesMessage, TrieNodesMessage,
6};
7
8#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum SnapResponse {
11 AccountRange(AccountRangeMessage),
13 StorageRanges(StorageRangesMessage),
15 ByteCodes(ByteCodesMessage),
17 TrieNodes(TrieNodesMessage),
19}
20
21#[auto_impl::auto_impl(&, Arc, Box)]
23pub trait SnapClient: DownloadClient {
24 type Output: Future<Output = PeerRequestResult<SnapResponse>> + Send + Sync + Unpin;
26
27 fn get_account_range(&self, request: GetAccountRangeMessage) -> Self::Output {
30 self.get_account_range_with_priority(request, Priority::Normal)
31 }
32
33 fn get_account_range_with_priority(
36 &self,
37 request: GetAccountRangeMessage,
38 priority: Priority,
39 ) -> Self::Output;
40
41 fn get_storage_ranges(&self, request: GetStorageRangesMessage) -> Self::Output;
44
45 fn get_storage_ranges_with_priority(
48 &self,
49 request: GetStorageRangesMessage,
50 priority: Priority,
51 ) -> Self::Output;
52
53 fn get_byte_codes(&self, request: GetByteCodesMessage) -> Self::Output;
56
57 fn get_byte_codes_with_priority(
60 &self,
61 request: GetByteCodesMessage,
62 priority: Priority,
63 ) -> Self::Output;
64
65 fn get_trie_nodes(&self, request: GetTrieNodesMessage) -> Self::Output;
68
69 fn get_trie_nodes_with_priority(
72 &self,
73 request: GetTrieNodesMessage,
74 priority: Priority,
75 ) -> Self::Output;
76}