@@ -27,7 +27,7 @@ use tox_packet::ip_port::*;
2727use crate :: onion:: client:: errors:: * ;
2828use crate :: onion:: client:: onion_path:: * ;
2929use crate :: onion:: client:: paths_pool:: * ;
30- use crate :: onion:: onion_announce:: INITIAL_PING_ID ;
30+ use crate :: onion:: onion_announce:: { PingId , INITIAL_PING_ID } ;
3131use tox_packet:: onion:: * ;
3232use tox_packet:: packed_node:: * ;
3333use crate :: relay:: client:: Connections as TcpConnections ;
@@ -169,7 +169,7 @@ struct OnionNode {
169169 /// Path used to send packets to this node.
170170 path_id : OnionPathId ,
171171 /// Ping id that should be used to announce to this node.
172- ping_id : Option < sha256 :: Digest > ,
172+ ping_id : Option < PingId > ,
173173 /// Data `PublicKey` that should be used to send data packets to our friend
174174 /// through this node.
175175 data_pk : Option < PublicKey > ,
@@ -268,7 +268,7 @@ struct AnnouncePacketData<'a> {
268268impl < ' a > AnnouncePacketData < ' a > {
269269 /// Create `InnerOnionAnnounceRequest`. The request is a search request if
270270 /// pind_id is 0 and an announce request otherwise.
271- fn request ( & self , node_pk : & PublicKey , ping_id : Option < sha256 :: Digest > , request_id : u64 ) -> InnerOnionAnnounceRequest {
271+ fn request ( & self , node_pk : & PublicKey , ping_id : Option < PingId > , request_id : u64 ) -> InnerOnionAnnounceRequest {
272272 let payload = OnionAnnounceRequestPayload {
273273 ping_id : ping_id. unwrap_or ( INITIAL_PING_ID ) ,
274274 search_pk : self . search_pk ,
@@ -286,7 +286,7 @@ impl<'a> AnnouncePacketData<'a> {
286286 self . request ( node_pk, None , request_id)
287287 }
288288 /// Create `InnerOnionAnnounceRequest` for an announce request.
289- pub fn announce_request ( & self , node_pk : & PublicKey , ping_id : sha256 :: Digest , request_id : u64 ) -> InnerOnionAnnounceRequest {
289+ pub fn announce_request ( & self , node_pk : & PublicKey , ping_id : PingId , request_id : u64 ) -> InnerOnionAnnounceRequest {
290290 self . request ( node_pk, Some ( ping_id) , request_id)
291291 }
292292}
@@ -469,7 +469,7 @@ impl OnionClient {
469469 let ( ping_id, data_pk) = if payload. announce_status == AnnounceStatus :: Found {
470470 ( None , Some ( PublicKey ( payload. ping_id_or_pk ) ) )
471471 } else {
472- ( Some ( sha256 :: Digest ( payload. ping_id_or_pk ) ) , None )
472+ ( Some ( payload. ping_id_or_pk ) , None )
473473 } ;
474474
475475 let now = clock_now ( ) ;
@@ -1021,7 +1021,7 @@ mod tests {
10211021 keys : [ gen_keypair ( ) . 0 , gen_keypair ( ) . 0 , gen_keypair ( ) . 0 ] ,
10221022 path_type : OnionPathType :: Udp ,
10231023 } ;
1024- let ping_id = sha256 :: hash ( & [ 1 , 2 , 3 ] ) ;
1024+ let ping_id = [ 42 ; 32 ] ;
10251025 let data_pk = gen_keypair ( ) . 0 ;
10261026 let new_now = now + Duration :: from_secs ( 1 ) ;
10271027 let other_onion_node = OnionNode {
@@ -1228,7 +1228,7 @@ mod tests {
12281228 // The sender should be added to close nodes
12291229 let onion_node = state. announce_list . get_node ( & real_pk, & sender_pk) . unwrap ( ) ;
12301230 assert_eq ! ( onion_node. path_id, path. id( ) ) ;
1231- assert_eq ! ( onion_node. ping_id, Some ( sha256 :: Digest ( ping_id) ) ) ;
1231+ assert_eq ! ( onion_node. ping_id, Some ( ping_id) ) ;
12321232 assert_eq ! ( onion_node. data_pk, None ) ;
12331233 assert_eq ! ( onion_node. announce_status, AnnounceStatus :: Announced ) ;
12341234
@@ -1920,7 +1920,7 @@ mod tests {
19201920 state. paths_pool . path_nodes . put ( node) ;
19211921 }
19221922
1923- let ping_id = sha256 :: hash ( & [ 1 , 2 , 3 ] ) ;
1923+ let ping_id = [ 42 ; 32 ] ;
19241924 let now = Instant :: now ( ) ;
19251925
19261926 let mut nodes_key_by_addr = HashMap :: new ( ) ;
@@ -2064,7 +2064,7 @@ mod tests {
20642064 saddr,
20652065 path_id : path. id ( ) ,
20662066 // regardless of this ping_id search requests should contain 0
2067- ping_id : Some ( sha256 :: hash ( & [ 1 , 2 , 3 ] ) ) ,
2067+ ping_id : Some ( [ 42 ; 32 ] ) ,
20682068 data_pk : None ,
20692069 unsuccessful_pings : 0 ,
20702070 added_time : now,
0 commit comments