@@ -84,19 +84,21 @@ impl<N: Network> Telemetry<N> {
8484 }
8585 }
8686
87- // TODO (raychu86): Consider using committee lookback here .
88- /// Fetch the participation scores for each validator in the committee set .
89- pub fn get_participation_scores ( & self , committee : & Committee < N > ) -> IndexMap < Address < N > , f64 > {
87+ /// Fetch the certificate and signature participation scores for each validator in the committee set .
88+ /// Returns a map of `address` to `(certificate_score, signature_score)` .
89+ pub fn get_participation_scores ( & self , committee : & Committee < N > ) -> IndexMap < Address < N > , ( f64 , f64 ) > {
9090 // Fetch the participation scores.
9191 let participation_scores = self . participation_scores . read ( ) ;
92- // Calculate the weighted score for each validator.
92+ // Return the individual scores for each validator.
9393 committee
9494 . members ( )
9595 . iter ( )
9696 . map ( |( address, _) | {
97- let score =
98- participation_scores. get ( address) . map ( |( _, _, combined_score) | * combined_score) . unwrap_or ( 0.0 ) ;
99- ( * address, score)
97+ let scores = participation_scores
98+ . get ( address)
99+ . map ( |( cert_score, sig_score, _) | ( * cert_score, * sig_score) )
100+ . unwrap_or ( ( 0.0 , 0.0 ) ) ;
101+ ( * address, scores)
100102 } )
101103 . collect ( )
102104 }
@@ -326,7 +328,7 @@ mod tests {
326328 let participation_scores = telemetry. get_participation_scores ( & committee) ;
327329 assert_eq ! ( participation_scores. len( ) , committee. members( ) . len( ) ) ;
328330 for ( address, _) in committee. members ( ) {
329- assert_eq ! ( * participation_scores. get( address) . unwrap( ) , 0.0 ) ;
331+ assert_eq ! ( * participation_scores. get( address) . unwrap( ) , ( 0.0 , 0.0 ) ) ;
330332 }
331333
332334 // Calculate the participation scores.
@@ -335,7 +337,8 @@ mod tests {
335337 // Ensure that the participation scores are updated.
336338 let participation_scores = telemetry. get_participation_scores ( & committee) ;
337339 for ( address, _) in committee. members ( ) {
338- assert ! ( * participation_scores. get( address) . unwrap( ) > 0.0 ) ;
340+ let ( cert_score, sig_score) = * participation_scores. get ( address) . unwrap ( ) ;
341+ assert ! ( cert_score > 0.0 || sig_score > 0.0 ) ;
339342 }
340343
341344 println ! ( "{participation_scores:?}" ) ;
0 commit comments