18
18
cluster_info_metrics:: { Counter , GossipStats , ScopedTimer , TimedGuard } ,
19
19
contact_info:: { self , ContactInfo , ContactInfoQuery , Error as ContactInfoError } ,
20
20
crds:: { Crds , Cursor , GossipRoute } ,
21
- crds_data:: { self , CrdsData , EpochSlotsIndex , LowestSlot , SnapshotHashes , Vote } ,
21
+ crds_data:: { self , CrdsData , EpochSlotsIndex , LowestSlot , SnapshotHashes , Vote , MAX_VOTES } ,
22
22
crds_gossip:: CrdsGossip ,
23
23
crds_gossip_error:: CrdsGossipError ,
24
24
crds_gossip_pull:: {
76
76
solana_time_utils:: timestamp,
77
77
solana_transaction:: Transaction ,
78
78
solana_vote:: vote_parser,
79
- solana_vote_program:: vote_state:: MAX_LOCKOUT_HISTORY ,
80
79
std:: {
81
80
borrow:: Borrow ,
82
81
collections:: { HashMap , HashSet , VecDeque } ,
@@ -786,7 +785,7 @@ impl ClusterInfo {
786
785
}
787
786
788
787
pub fn push_vote_at_index ( & self , vote : Transaction , vote_index : u8 ) {
789
- assert ! ( ( vote_index as usize ) < MAX_LOCKOUT_HISTORY ) ;
788
+ assert ! ( vote_index < MAX_VOTES ) ;
790
789
let self_pubkey = self . id ( ) ;
791
790
let now = timestamp ( ) ;
792
791
let vote = Vote :: new ( self_pubkey, vote, now) . unwrap ( ) ;
@@ -812,7 +811,7 @@ impl ClusterInfo {
812
811
let vote_index = {
813
812
let gossip_crds =
814
813
self . time_gossip_read_lock ( "gossip_read_push_vote" , & self . stats . push_vote_read ) ;
815
- ( 0 ..MAX_LOCKOUT_HISTORY as u8 )
814
+ ( 0 ..MAX_VOTES )
816
815
. filter_map ( |ix| {
817
816
let vote = CrdsValueLabel :: Vote ( ix, self_pubkey) ;
818
817
let vote: & CrdsData = gossip_crds. get ( & vote) ?;
@@ -834,7 +833,7 @@ impl ClusterInfo {
834
833
if exists_newer_vote {
835
834
return None ;
836
835
}
837
- if num_crds_votes < MAX_LOCKOUT_HISTORY as u8 {
836
+ if num_crds_votes < MAX_VOTES {
838
837
// Do not evict if there is space in crds
839
838
Some ( num_crds_votes)
840
839
} else {
@@ -859,7 +858,7 @@ impl ClusterInfo {
859
858
tower
860
859
) ;
861
860
} ;
862
- debug_assert ! ( vote_index < MAX_LOCKOUT_HISTORY as u8 ) ;
861
+ debug_assert ! ( vote_index < MAX_VOTES ) ;
863
862
self . push_vote_at_index ( vote, vote_index) ;
864
863
}
865
864
@@ -868,7 +867,7 @@ impl ClusterInfo {
868
867
let self_pubkey = self . id ( ) ;
869
868
let gossip_crds =
870
869
self . time_gossip_read_lock ( "gossip_read_push_vote" , & self . stats . push_vote_read ) ;
871
- ( 0 ..MAX_LOCKOUT_HISTORY as u8 ) . find ( |ix| {
870
+ ( 0 ..MAX_VOTES ) . find ( |ix| {
872
871
let vote = CrdsValueLabel :: Vote ( * ix, self_pubkey) ;
873
872
let Some ( vote) = gossip_crds. get :: < & CrdsData > ( & vote) else {
874
873
return false ;
@@ -900,7 +899,7 @@ impl ClusterInfo {
900
899
) ;
901
900
return ;
902
901
} ;
903
- debug_assert ! ( vote_index < MAX_LOCKOUT_HISTORY as u8 ) ;
902
+ debug_assert ! ( vote_index < MAX_VOTES ) ;
904
903
self . push_vote_at_index ( refresh_vote, vote_index) ;
905
904
}
906
905
}
@@ -3072,7 +3071,10 @@ mod tests {
3072
3071
solana_ledger:: shred:: Shredder ,
3073
3072
solana_net_utils:: bind_to,
3074
3073
solana_signer:: Signer ,
3075
- solana_vote_program:: { vote_instruction, vote_state:: Vote } ,
3074
+ solana_vote_program:: {
3075
+ vote_instruction,
3076
+ vote_state:: { Vote , MAX_LOCKOUT_HISTORY } ,
3077
+ } ,
3076
3078
std:: {
3077
3079
iter:: repeat_with,
3078
3080
net:: { IpAddr , Ipv4Addr } ,
@@ -3483,7 +3485,7 @@ mod tests {
3483
3485
}
3484
3486
3485
3487
let initial_votes = cluster_info. get_votes ( & mut Cursor :: default ( ) ) ;
3486
- assert_eq ! ( initial_votes. len( ) , MAX_LOCKOUT_HISTORY ) ;
3488
+ assert_eq ! ( initial_votes. len( ) , MAX_VOTES as usize ) ;
3487
3489
3488
3490
// Trying to refresh a vote less than all votes in gossip should do nothing
3489
3491
let refresh_slot = lowest_vote_slot - 1 ;
@@ -3518,7 +3520,7 @@ mod tests {
3518
3520
3519
3521
// This should evict the latest vote since it's for a slot less than refresh_slot
3520
3522
let votes = cluster_info. get_votes ( & mut Cursor :: default ( ) ) ;
3521
- assert_eq ! ( votes. len( ) , MAX_LOCKOUT_HISTORY ) ;
3523
+ assert_eq ! ( votes. len( ) , MAX_VOTES as usize ) ;
3522
3524
assert ! ( votes. contains( & refresh_tx) ) ;
3523
3525
assert ! ( !votes. contains( & first_vote. unwrap( ) ) ) ;
3524
3526
}
@@ -3688,7 +3690,7 @@ mod tests {
3688
3690
cluster_info. push_vote ( & tower, vote) ;
3689
3691
3690
3692
let vote_slots = get_vote_slots ( & cluster_info) ;
3691
- let min_vote = k. saturating_sub ( MAX_LOCKOUT_HISTORY - 1 ) as u64 ;
3693
+ let min_vote = k. saturating_sub ( MAX_VOTES as usize - 1 ) as u64 ;
3692
3694
assert ! ( vote_slots. into_iter( ) . eq( min_vote..=( k as u64 ) ) ) ;
3693
3695
sleep ( Duration :: from_millis ( 1 ) ) ;
3694
3696
}
0 commit comments