1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use crate::types::portal::FindNodesInfo;
use crate::types::{
content_item::HistoryContentItem,
content_key::HistoryContentKey,
discv5::{Enr, NodeId, RoutingTableInfo},
portal::{
AcceptInfo, ContentInfo, DataRadius, PaginateLocalContentInfo, PongInfo, TraceContentInfo,
},
};
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
#[rpc(client, server, namespace = "portal")]
pub trait HistoryNetworkApi {
#[method(name = "historyRoutingTableInfo")]
async fn routing_table_info(&self) -> RpcResult<RoutingTableInfo>;
#[method(name = "historyRadius")]
async fn radius(&self) -> RpcResult<DataRadius>;
#[method(name = "historyAddEnr")]
async fn add_enr(&self, enr: Enr) -> RpcResult<bool>;
#[method(name = "historyGetEnr")]
async fn get_enr(&self, node_id: NodeId) -> RpcResult<Enr>;
#[method(name = "historyDeleteEnr")]
async fn delete_enr(&self, node_id: NodeId) -> RpcResult<bool>;
#[method(name = "historyLookupEnr")]
async fn lookup_enr(&self, node_id: NodeId, enr_seq: Option<u32>) -> RpcResult<Enr>;
#[method(name = "historyPing")]
async fn ping(&self, enr: Enr, data_radius: Option<DataRadius>) -> RpcResult<PongInfo>;
#[method(name = "historyFindNodes")]
async fn find_nodes(&self, enr: Enr, distances: Vec<u16>) -> RpcResult<FindNodesInfo>;
#[method(name = "historyRecursiveFindNodes")]
async fn recursive_find_nodes(&self, node_id: NodeId) -> RpcResult<Vec<Enr>>;
#[method(name = "historyFindContent")]
async fn find_content(
&self,
enr: Enr,
content_key: HistoryContentKey,
) -> RpcResult<ContentInfo>;
#[method(name = "historyRecursiveFindContent")]
async fn recursive_find_content(
&self,
content_key: HistoryContentKey,
) -> RpcResult<HistoryContentItem>;
#[method(name = "historyTraceRecursiveFindContent")]
async fn trace_recursive_find_content(
&self,
content_key: HistoryContentKey,
) -> RpcResult<TraceContentInfo>;
#[method(name = "paginateLocalContentKeys")]
async fn paginate_local_content_keys(
&self,
offset: u64,
limit: u64,
) -> RpcResult<PaginateLocalContentInfo>;
#[method(name = "historyGossip")]
async fn gossip(
&self,
content_key: HistoryContentKey,
content_value: HistoryContentItem,
) -> RpcResult<u32>;
#[method(name = "historyOffer")]
async fn offer(&self, enr: Enr, content_key: HistoryContentKey) -> RpcResult<AcceptInfo>;
#[method(name = "historyStore")]
async fn store(
&self,
content_key: HistoryContentKey,
content_value: HistoryContentItem,
) -> RpcResult<bool>;
#[method(name = "historyLocalContent")]
async fn local_content(&self, content_key: HistoryContentKey) -> RpcResult<HistoryContentItem>;
}