ethportal_api/
legacy_history.rs1use discv5::enr::NodeId;
2use jsonrpsee::{core::RpcResult, proc_macros::rpc};
3use serde_json::Value;
4
5use crate::{
6 types::{
7 enr::Enr,
8 ping_extensions::extension_types::PingExtensionType,
9 portal::{
10 AcceptInfo, DataRadius, FindContentInfo, FindNodesInfo, GetContentInfo,
11 PaginateLocalContentInfo, PongInfo, PutContentInfo, TraceContentInfo,
12 },
13 portal_wire::OfferTrace,
14 },
15 LegacyHistoryContentKey, RawContentValue, RoutingTableInfo,
16};
17
18#[rpc(client, server, namespace = "portal")]
20pub trait LegacyHistoryNetworkApi {
21 #[method(name = "legacyHistoryRoutingTableInfo")]
23 async fn routing_table_info(&self) -> RpcResult<RoutingTableInfo>;
24
25 #[method(name = "legacyHistoryRadius")]
27 async fn radius(&self) -> RpcResult<DataRadius>;
28
29 #[method(name = "legacyHistoryAddEnr")]
31 async fn add_enr(&self, enr: Enr) -> RpcResult<bool>;
32
33 #[method(name = "legacyHistoryGetEnr")]
35 async fn get_enr(&self, node_id: NodeId) -> RpcResult<Enr>;
36
37 #[method(name = "legacyHistoryDeleteEnr")]
39 async fn delete_enr(&self, node_id: NodeId) -> RpcResult<bool>;
40
41 #[method(name = "legacyHistoryLookupEnr")]
43 async fn lookup_enr(&self, node_id: NodeId) -> RpcResult<Enr>;
44
45 #[method(name = "legacyHistoryPing")]
47 async fn ping(
48 &self,
49 enr: Enr,
50 payload_type: Option<PingExtensionType>,
51 payload: Option<Value>,
52 ) -> RpcResult<PongInfo>;
53
54 #[method(name = "legacyHistoryFindNodes")]
57 async fn find_nodes(&self, enr: Enr, distances: Vec<u16>) -> RpcResult<FindNodesInfo>;
58
59 #[method(name = "legacyHistoryRecursiveFindNodes")]
61 async fn recursive_find_nodes(&self, node_id: NodeId) -> RpcResult<Vec<Enr>>;
62
63 #[method(name = "legacyHistoryFindContent")]
65 async fn find_content(
66 &self,
67 enr: Enr,
68 content_key: LegacyHistoryContentKey,
69 ) -> RpcResult<FindContentInfo>;
70
71 #[method(name = "legacyHistoryGetContent")]
74 async fn get_content(&self, content_key: LegacyHistoryContentKey) -> RpcResult<GetContentInfo>;
75
76 #[method(name = "legacyHistoryTraceGetContent")]
79 async fn trace_get_content(
80 &self,
81 content_key: LegacyHistoryContentKey,
82 ) -> RpcResult<TraceContentInfo>;
83
84 #[method(name = "legacyHistoryPaginateLocalContentKeys")]
86 async fn paginate_local_content_keys(
87 &self,
88 offset: u64,
89 limit: u64,
90 ) -> RpcResult<PaginateLocalContentInfo<LegacyHistoryContentKey>>;
91
92 #[method(name = "legacyHistoryPutContent")]
95 async fn put_content(
96 &self,
97 content_key: LegacyHistoryContentKey,
98 content_value: RawContentValue,
99 ) -> RpcResult<PutContentInfo>;
100
101 #[method(name = "legacyHistoryOffer")]
106 async fn offer(
107 &self,
108 enr: Enr,
109 content_items: Vec<(LegacyHistoryContentKey, RawContentValue)>,
110 ) -> RpcResult<AcceptInfo>;
111
112 #[method(name = "legacyHistoryTraceOffer")]
116 async fn trace_offer(
117 &self,
118 enr: Enr,
119 content_key: LegacyHistoryContentKey,
120 content_value: RawContentValue,
121 ) -> RpcResult<OfferTrace>;
122
123 #[method(name = "legacyHistoryStore")]
125 async fn store(
126 &self,
127 content_key: LegacyHistoryContentKey,
128 content_value: RawContentValue,
129 ) -> RpcResult<bool>;
130
131 #[method(name = "legacyHistoryLocalContent")]
133 async fn local_content(
134 &self,
135 content_key: LegacyHistoryContentKey,
136 ) -> RpcResult<RawContentValue>;
137}