1use discv5::enr::NodeId;
2use jsonrpsee::{core::RpcResult, proc_macros::rpc};
3
4use crate::{
5 types::{
6 content_key::history::HistoryContentKey,
7 enr::Enr,
8 portal::{
9 AcceptInfo, DataRadius, FindContentInfo, FindNodesInfo, GetContentInfo,
10 PaginateLocalContentInfo, PongInfo, PutContentInfo, TraceContentInfo,
11 TracePutContentInfo,
12 },
13 portal_wire::OfferTrace,
14 },
15 RawContentValue, RoutingTableInfo,
16};
17
18#[rpc(client, server, namespace = "portal")]
20pub trait HistoryNetworkApi {
21 #[method(name = "historyRoutingTableInfo")]
23 async fn routing_table_info(&self) -> RpcResult<RoutingTableInfo>;
24
25 #[method(name = "historyRadius")]
27 async fn radius(&self) -> RpcResult<DataRadius>;
28
29 #[method(name = "historyAddEnr")]
31 async fn add_enr(&self, enr: Enr) -> RpcResult<bool>;
32
33 #[method(name = "historyGetEnr")]
35 async fn get_enr(&self, node_id: NodeId) -> RpcResult<Enr>;
36
37 #[method(name = "historyDeleteEnr")]
39 async fn delete_enr(&self, node_id: NodeId) -> RpcResult<bool>;
40
41 #[method(name = "historyLookupEnr")]
43 async fn lookup_enr(&self, node_id: NodeId) -> RpcResult<Enr>;
44
45 #[method(name = "historyPing")]
47 async fn ping(&self, enr: Enr) -> RpcResult<PongInfo>;
48
49 #[method(name = "historyFindNodes")]
52 async fn find_nodes(&self, enr: Enr, distances: Vec<u16>) -> RpcResult<FindNodesInfo>;
53
54 #[method(name = "historyRecursiveFindNodes")]
56 async fn recursive_find_nodes(&self, node_id: NodeId) -> RpcResult<Vec<Enr>>;
57
58 #[method(name = "historyFindContent")]
60 async fn find_content(
61 &self,
62 enr: Enr,
63 content_key: HistoryContentKey,
64 ) -> RpcResult<FindContentInfo>;
65
66 #[method(name = "historyGetContent")]
69 async fn get_content(&self, content_key: HistoryContentKey) -> RpcResult<GetContentInfo>;
70
71 #[method(name = "historyTraceGetContent")]
74 async fn trace_get_content(
75 &self,
76 content_key: HistoryContentKey,
77 ) -> RpcResult<TraceContentInfo>;
78
79 #[method(name = "historyPaginateLocalContentKeys")]
81 async fn paginate_local_content_keys(
82 &self,
83 offset: u64,
84 limit: u64,
85 ) -> RpcResult<PaginateLocalContentInfo<HistoryContentKey>>;
86
87 #[method(name = "historyPutContent")]
90 async fn put_content(
91 &self,
92 content_key: HistoryContentKey,
93 content_value: RawContentValue,
94 ) -> RpcResult<PutContentInfo>;
95
96 #[method(name = "historyTracePutContent")]
99 async fn trace_put_content(
100 &self,
101 content_key: HistoryContentKey,
102 content_value: RawContentValue,
103 ) -> RpcResult<TracePutContentInfo>;
104
105 #[method(name = "historyOffer")]
110 async fn offer(
111 &self,
112 enr: Enr,
113 content_items: Vec<(HistoryContentKey, RawContentValue)>,
114 ) -> RpcResult<AcceptInfo>;
115
116 #[method(name = "historyTraceOffer")]
120 async fn trace_offer(
121 &self,
122 enr: Enr,
123 content_key: HistoryContentKey,
124 content_value: RawContentValue,
125 ) -> RpcResult<OfferTrace>;
126
127 #[method(name = "historyStore")]
129 async fn store(
130 &self,
131 content_key: HistoryContentKey,
132 content_value: RawContentValue,
133 ) -> RpcResult<bool>;
134
135 #[method(name = "historyLocalContent")]
137 async fn local_content(&self, content_key: HistoryContentKey) -> RpcResult<RawContentValue>;
138}