@@ -2,7 +2,11 @@ use std::sync::Arc;
22
33use slog:: { Logger , error, warn} ;
44
5- use mithril_common:: { StdResult , logging:: LoggerExtensions } ;
5+ use mithril_common:: {
6+ StdResult ,
7+ entities:: { SingleSignature , SingleSignatureAuthenticationStatus } ,
8+ logging:: LoggerExtensions ,
9+ } ;
610use tokio:: { select, sync:: watch:: Receiver } ;
711
812use crate :: MetricsService ;
@@ -46,14 +50,22 @@ impl SequentialSignatureProcessor {
4650 metrics_service,
4751 }
4852 }
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+ }
4960}
5061
5162#[ async_trait:: async_trait]
5263impl SignatureProcessor for SequentialSignatureProcessor {
5364 async fn process_signatures ( & self ) -> StdResult < ( ) > {
5465 match self . consumer . get_signatures ( ) . await {
5566 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) ;
5769 match self
5870 . certifier
5971 . register_single_signature ( & signed_entity_type, & signature)
@@ -150,15 +162,27 @@ mod tests {
150162 . expect_register_single_signature ( )
151163 . with (
152164 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+ } ) ,
154169 )
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+ } )
156177 . times ( 1 ) ;
157178 mock_certifier
158179 . expect_register_single_signature ( )
159180 . with (
160181 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+ } ) ,
162186 )
163187 . returning ( |_, _| Ok ( SignatureRegistrationStatus :: Registered ) )
164188 . times ( 1 ) ;
@@ -207,7 +231,10 @@ mod tests {
207231 . expect_register_single_signature ( )
208232 . with (
209233 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+ } ) ,
211238 )
212239 . returning ( |_, _| Ok ( SignatureRegistrationStatus :: Registered ) )
213240 . times ( 1 ) ;
0 commit comments