LCOV - code coverage report
Current view: top level - choreo/voter - fd_voter.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 6 32 18.8 %
Date: 2026-01-21 05:06:28 Functions: 1 4 25.0 %

          Line data    Source code
       1             : #include "fd_voter.h"
       2             : 
       3             : ulong
       4         264 : fd_voter_votes_cnt( uchar const * vote_account_data ) {
       5         264 :   fd_voter_t const * voter = (fd_voter_t const *)fd_type_pun_const( vote_account_data );
       6         264 :   switch( voter->kind ) {
       7           0 :   case FD_VOTER_V4: return fd_ulong_load_8( voter->v4.bls_pubkey_compressed + voter->v4.has_bls_pubkey_compressed * sizeof(voter->v4.bls_pubkey_compressed) );
       8         264 :   case FD_VOTER_V3: return voter->v3.votes_cnt;
       9           0 :   case FD_VOTER_V2: return voter->v2.votes_cnt;
      10           0 :   default:          FD_LOG_HEXDUMP_CRIT(( "bad voter", vote_account_data, 3762 ));
      11         264 :   }
      12         264 : }
      13             : 
      14             : fd_voter_vote_t const *
      15           0 : v4_off( fd_voter_t const * voter ) {
      16           0 :   return (fd_voter_vote_t const *)( voter->v4.bls_pubkey_compressed + voter->v4.has_bls_pubkey_compressed * sizeof(voter->v4.bls_pubkey_compressed) + sizeof(ulong) );
      17           0 : }
      18             : 
      19             : /* fd_voter_vote_slot takes a voter's vote account data and returns the
      20             :    voter's most recent vote slot in the tower.  Returns ULONG_MAX if
      21             :    they have an empty tower. */
      22             : 
      23             : ulong
      24           0 : fd_voter_vote_slot( uchar const * vote_account_data ) {
      25           0 :   fd_voter_t const * voter = (fd_voter_t const *)fd_type_pun_const( vote_account_data );
      26           0 :   ulong              cnt   = fd_voter_votes_cnt( vote_account_data );
      27           0 :   switch( voter->kind ) {
      28           0 :   case FD_VOTER_V4: return cnt ? v4_off( voter )[cnt-1].slot : ULONG_MAX;
      29           0 :   case FD_VOTER_V3: return cnt ? voter->v3.votes[cnt-1].slot : ULONG_MAX;
      30           0 :   case FD_VOTER_V2: return cnt ? voter->v2.votes[cnt-1].slot : ULONG_MAX;
      31           0 :   default:          FD_LOG_HEXDUMP_CRIT(( "bad voter", vote_account_data, 3762 ));
      32           0 :   }
      33           0 : }
      34             : 
      35             : /* fd_voter_root_slot takes a voter's vote account data and returns the
      36             :    voter's root slot.  Returns ULONG_MAX if they don't have a root. */
      37             : 
      38             : ulong
      39           0 : fd_voter_root_slot( uchar const * vote_account_data ) {
      40           0 :   fd_voter_t const * voter = (fd_voter_t const *)fd_type_pun_const( vote_account_data );
      41           0 :   ulong              cnt   = fd_voter_votes_cnt( vote_account_data );
      42           0 :   switch( voter->kind ) {
      43           0 :   case FD_VOTER_V4: { uchar root_option = fd_uchar_load_1_fast( (uchar *)&v4_off( voter )[cnt] ); return root_option ? fd_ulong_load_8_fast( (uchar *)&v4_off( voter )[cnt] + 1UL ) : ULONG_MAX; }
      44           0 :   case FD_VOTER_V3: { uchar root_option = fd_uchar_load_1_fast( (uchar *)&voter->v3.votes[cnt] ); return root_option ? fd_ulong_load_8_fast( (uchar *)&voter->v3.votes[cnt] + 1UL ) : ULONG_MAX; }
      45           0 :   case FD_VOTER_V2: { uchar root_option = fd_uchar_load_1_fast( (uchar *)&voter->v2.votes[cnt] ); return root_option ? fd_ulong_load_8_fast( (uchar *)&voter->v2.votes[cnt] + 1UL ) : ULONG_MAX; }
      46           0 :   default:          FD_LOG_CRIT(( "unhandled kind %u", voter->kind ));
      47           0 :   }
      48           0 : }

Generated by: LCOV version 1.14