@@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
19
19
/// - version is given within the Identify protocol
20
20
/// - timestamp is available at protocol level via DataTransform
21
21
#[ derive( Serialize , Deserialize , Debug , Clone ) ]
22
- pub struct P2PMessage {
22
+ pub struct DKNMessage {
23
23
pub ( crate ) payload : String ,
24
24
pub ( crate ) topic : String ,
25
25
pub ( crate ) version : String ,
@@ -33,7 +33,7 @@ pub struct P2PMessage {
33
33
/// and therefore use 128 characters: SIGNATURE_SIZE - 2.
34
34
const SIGNATURE_SIZE_HEX : usize = 130 ;
35
35
36
- impl P2PMessage {
36
+ impl DKNMessage {
37
37
/// Creates a new message with current timestamp and version equal to the crate version.
38
38
///
39
39
/// - `payload` is gives as bytes. It is to be `base64` encoded internally.
@@ -91,7 +91,6 @@ impl P2PMessage {
91
91
ciphertext : hex:: encode ( ciphertext) ,
92
92
signature : format ! ( "{}{}" , hex:: encode( signature) , hex:: encode( recid) ) ,
93
93
task_id : task_id. to_string ( ) ,
94
- timestamp : get_current_time_nanos ( ) ,
95
94
} )
96
95
}
97
96
@@ -136,7 +135,7 @@ impl P2PMessage {
136
135
}
137
136
}
138
137
139
- impl fmt:: Display for P2PMessage {
138
+ impl fmt:: Display for DKNMessage {
140
139
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
141
140
let payload_decoded = self
142
141
. decode_payload ( )
@@ -151,7 +150,7 @@ impl fmt::Display for P2PMessage {
151
150
}
152
151
}
153
152
154
- impl TryFrom < libp2p:: gossipsub:: Message > for P2PMessage {
153
+ impl TryFrom < libp2p:: gossipsub:: Message > for DKNMessage {
155
154
type Error = serde_json:: Error ;
156
155
157
156
fn try_from ( value : libp2p:: gossipsub:: Message ) -> Result < Self , Self :: Error > {
@@ -186,7 +185,7 @@ mod tests {
186
185
187
186
#[ test]
188
187
fn test_display_message ( ) {
189
- let message = P2PMessage :: new ( b"hello world" , "test-topic" ) ;
188
+ let message = DKNMessage :: new ( b"hello world" , "test-topic" ) ;
190
189
println ! ( "{}" , message) ;
191
190
}
192
191
@@ -195,7 +194,7 @@ mod tests {
195
194
// create payload & message
196
195
let body = TestStruct :: default ( ) ;
197
196
let payload = serde_json:: to_vec ( & json ! ( body) ) . expect ( "Should serialize" ) ;
198
- let message = P2PMessage :: new ( payload, TOPIC ) ;
197
+ let message = DKNMessage :: new ( payload, TOPIC ) ;
199
198
200
199
// decode message
201
200
let message_body = message. decode_payload ( ) . expect ( "Should decode" ) ;
@@ -221,7 +220,7 @@ mod tests {
221
220
// create payload & message with signature & body
222
221
let body = TestStruct :: default ( ) ;
223
222
let body_str = serde_json:: to_string ( & body) . unwrap ( ) ;
224
- let message = P2PMessage :: new_signed ( body_str, TOPIC , & sk) ;
223
+ let message = DKNMessage :: new_signed ( body_str, TOPIC , & sk) ;
225
224
226
225
// decode message
227
226
let message_body = message. decode_payload ( ) . expect ( "Should decode" ) ;
@@ -253,7 +252,7 @@ mod tests {
253
252
let task_public_key = PublicKey :: from_secret_key ( & task_secret_key) ;
254
253
255
254
// create payload
256
- let payload = P2PMessage :: new_signed_encrypted_payload (
255
+ let payload = DKNMessage :: new_signed_encrypted_payload (
257
256
RESULT ,
258
257
TASK_ID ,
259
258
& task_public_key. serialize ( ) ,
0 commit comments