@@ -2,7 +2,11 @@ use std::sync::Arc;
2
2
3
3
use slog:: { Logger , error, warn} ;
4
4
5
- use mithril_common:: { StdResult , logging:: LoggerExtensions } ;
5
+ use mithril_common:: {
6
+ StdResult ,
7
+ entities:: { SingleSignature , SingleSignatureAuthenticationStatus } ,
8
+ logging:: LoggerExtensions ,
9
+ } ;
6
10
use tokio:: { select, sync:: watch:: Receiver } ;
7
11
8
12
use crate :: MetricsService ;
@@ -46,14 +50,22 @@ impl SequentialSignatureProcessor {
46
50
metrics_service,
47
51
}
48
52
}
53
+
54
+ /// Authenticates a single signature
55
+ ///
56
+ /// This is always the case with single signatures received from the DMQ network.
57
+ fn authenticate_signature ( & self , signature : & mut SingleSignature ) {
58
+ signature. authentication_status = SingleSignatureAuthenticationStatus :: Authenticated ;
59
+ }
49
60
}
50
61
51
62
#[ async_trait:: async_trait]
52
63
impl SignatureProcessor for SequentialSignatureProcessor {
53
64
async fn process_signatures ( & self ) -> StdResult < ( ) > {
54
65
match self . consumer . get_signatures ( ) . await {
55
66
Ok ( signatures) => {
56
- for ( signature, signed_entity_type) in signatures {
67
+ for ( mut signature, signed_entity_type) in signatures {
68
+ self . authenticate_signature ( & mut signature) ;
57
69
match self
58
70
. certifier
59
71
. register_single_signature ( & signed_entity_type, & signature)
@@ -150,15 +162,27 @@ mod tests {
150
162
. expect_register_single_signature ( )
151
163
. with (
152
164
eq ( SignedEntityType :: MithrilStakeDistribution ( Epoch ( 1 ) ) ) ,
153
- eq ( fake_data:: single_signature ( vec ! [ 1 , 2 , 3 ] ) ) ,
165
+ eq ( SingleSignature {
166
+ authentication_status : SingleSignatureAuthenticationStatus :: Authenticated ,
167
+ ..fake_data:: single_signature ( vec ! [ 1 , 2 , 3 ] )
168
+ } ) ,
154
169
)
155
- . returning ( |_, _| Ok ( SignatureRegistrationStatus :: Registered ) )
170
+ . returning ( |_, single_signature| {
171
+ assert_eq ! (
172
+ single_signature. authentication_status,
173
+ SingleSignatureAuthenticationStatus :: Authenticated
174
+ ) ;
175
+ Ok ( SignatureRegistrationStatus :: Registered )
176
+ } )
156
177
. times ( 1 ) ;
157
178
mock_certifier
158
179
. expect_register_single_signature ( )
159
180
. with (
160
181
eq ( SignedEntityType :: MithrilStakeDistribution ( Epoch ( 2 ) ) ) ,
161
- eq ( fake_data:: single_signature ( vec ! [ 4 , 5 , 6 ] ) ) ,
182
+ eq ( SingleSignature {
183
+ authentication_status : SingleSignatureAuthenticationStatus :: Authenticated ,
184
+ ..fake_data:: single_signature ( vec ! [ 4 , 5 , 6 ] )
185
+ } ) ,
162
186
)
163
187
. returning ( |_, _| Ok ( SignatureRegistrationStatus :: Registered ) )
164
188
. times ( 1 ) ;
@@ -207,7 +231,10 @@ mod tests {
207
231
. expect_register_single_signature ( )
208
232
. with (
209
233
eq ( SignedEntityType :: MithrilStakeDistribution ( Epoch ( 1 ) ) ) ,
210
- eq ( fake_data:: single_signature ( vec ! [ 1 , 2 , 3 ] ) ) ,
234
+ eq ( SingleSignature {
235
+ authentication_status : SingleSignatureAuthenticationStatus :: Authenticated ,
236
+ ..fake_data:: single_signature ( vec ! [ 1 , 2 , 3 ] )
237
+ } ) ,
211
238
)
212
239
. returning ( |_, _| Ok ( SignatureRegistrationStatus :: Registered ) )
213
240
. times ( 1 ) ;
0 commit comments