@@ -59,7 +59,7 @@ pub enum NetAction {
59
59
/// get the [`Identity`] struct for a single peer
60
60
GetPeer ( String ) ,
61
61
/// get the [`NodeId`] associated with a given namehash, if any
62
- GetName ( String ) ,
62
+ NamehashToName ( NamehashToNameRequest ) ,
63
63
/// get a user-readable diagnostics string containing networking inforamtion
64
64
GetDiagnostics ,
65
65
/// sign the attached blob payload, sign with our node's networking key.
@@ -99,6 +99,16 @@ pub enum NetResponse {
99
99
Verified ( bool ) ,
100
100
}
101
101
102
+ //
103
+ // KNS parts of the networking protocol
104
+ //
105
+
106
+ #[ derive( Clone , Debug , Serialize , Deserialize , Hash , Eq , PartialEq ) ]
107
+ pub struct NamehashToNameRequest {
108
+ pub hash : String ,
109
+ pub block : Option < u64 > ,
110
+ }
111
+
102
112
#[ derive( Clone , Debug , Serialize , Deserialize , Hash , Eq , PartialEq ) ]
103
113
pub struct KnsUpdate {
104
114
pub name : String , // actual username / domain name
@@ -160,9 +170,19 @@ where
160
170
}
161
171
162
172
/// get a kimap name from namehash
163
- pub fn get_name ( namehash : & str , timeout : Option < u64 > ) -> anyhow:: Result < String > {
164
- let res = Request :: to ( ( "our" , "net" , "distro" , "sys" ) )
165
- . body ( rmp_serde:: to_vec ( & NetAction :: GetName ( namehash. to_string ( ) ) ) . unwrap ( ) )
173
+ pub fn get_name (
174
+ namehash : & str ,
175
+ block : Option < u64 > ,
176
+ timeout : Option < u64 > ,
177
+ ) -> anyhow:: Result < String > {
178
+ let res = Request :: to ( ( "our" , "kns_indexer" , "kns_indexer" , "sys" ) )
179
+ . body (
180
+ serde_json:: to_vec ( & NetAction :: NamehashToName ( NamehashToNameRequest {
181
+ hash : namehash. to_string ( ) ,
182
+ block : block,
183
+ } ) )
184
+ . unwrap ( ) ,
185
+ )
166
186
. send_and_await_response ( timeout. unwrap_or ( 5 ) ) ??;
167
187
168
188
let response = rmp_serde:: from_slice :: < NetResponse > ( res. body ( ) ) ?;
0 commit comments