@@ -5,12 +5,13 @@ use crate::{
5
5
} ,
6
6
entities:: { PartyId , Stake } ,
7
7
} ;
8
+ use std:: fmt:: { Debug , Formatter } ;
8
9
9
10
use serde:: { Deserialize , Serialize } ;
10
11
use sha2:: { Digest , Sha256 } ;
11
12
12
13
/// Signer represents a signing participant in the network
13
- #[ derive( Clone , Debug , Eq , Serialize , Deserialize ) ]
14
+ #[ derive( Clone , Eq , Serialize , Deserialize ) ]
14
15
pub struct Signer {
15
16
/// The unique identifier of the signer
16
17
// TODO: Should be removed once the signer certification is fully deployed
@@ -75,6 +76,33 @@ impl Signer {
75
76
}
76
77
}
77
78
79
+ impl Debug for Signer {
80
+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
81
+ let should_be_exhaustive = f. alternate ( ) ;
82
+ let mut debug = f. debug_struct ( "Signer" ) ;
83
+ debug. field ( "party_id" , & self . party_id ) ;
84
+
85
+ match should_be_exhaustive {
86
+ true => debug
87
+ . field (
88
+ "verification_key" ,
89
+ & format_args ! ( "{:?}" , self . verification_key) ,
90
+ )
91
+ . field (
92
+ "verification_key_signature" ,
93
+ & format_args ! ( "{:?}" , self . verification_key_signature) ,
94
+ )
95
+ . field (
96
+ "operational_certificate" ,
97
+ & format_args ! ( "{:?}" , self . operational_certificate) ,
98
+ )
99
+ . field ( "kes_period" , & format_args ! ( "{:?}" , self . kes_period) )
100
+ . finish ( ) ,
101
+ false => debug. finish_non_exhaustive ( ) ,
102
+ }
103
+ }
104
+ }
105
+
78
106
impl From < SignerWithStake > for Signer {
79
107
fn from ( other : SignerWithStake ) -> Self {
80
108
Signer :: new (
@@ -88,7 +116,7 @@ impl From<SignerWithStake> for Signer {
88
116
}
89
117
90
118
/// Signer represents a signing party in the network (including its stakes)
91
- #[ derive( Clone , Debug , Eq , Serialize , Deserialize ) ]
119
+ #[ derive( Clone , Eq , Serialize , Deserialize ) ]
92
120
pub struct SignerWithStake {
93
121
/// The unique identifier of the signer
94
122
// TODO: Should be removed once the signer certification is fully deployed
@@ -184,6 +212,35 @@ impl SignerWithStake {
184
212
}
185
213
}
186
214
215
+ impl Debug for SignerWithStake {
216
+ fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
217
+ let should_be_exhaustive = f. alternate ( ) ;
218
+ let mut debug = f. debug_struct ( "SignerWithStake" ) ;
219
+ debug
220
+ . field ( "party_id" , & self . party_id )
221
+ . field ( "stake" , & self . stake ) ;
222
+
223
+ match should_be_exhaustive {
224
+ true => debug
225
+ . field (
226
+ "verification_key" ,
227
+ & format_args ! ( "{:?}" , self . verification_key) ,
228
+ )
229
+ . field (
230
+ "verification_key_signature" ,
231
+ & format_args ! ( "{:?}" , self . verification_key_signature) ,
232
+ )
233
+ . field (
234
+ "operational_certificate" ,
235
+ & format_args ! ( "{:?}" , self . operational_certificate) ,
236
+ )
237
+ . field ( "kes_period" , & format_args ! ( "{:?}" , self . kes_period) )
238
+ . finish ( ) ,
239
+ false => debug. finish_non_exhaustive ( ) ,
240
+ }
241
+ }
242
+ }
243
+
187
244
#[ cfg( test) ]
188
245
mod tests {
189
246
use crate :: test_utils:: { fake_keys, MithrilFixtureBuilder } ;
0 commit comments