@@ -47,6 +47,9 @@ pub const VOTE_CREDITS_GRACE_SLOTS: u8 = 2;
47
47
// Maximum number of credits to award for a vote; this number of credits is awarded to votes on slots that land within the grace period. After that grace period, vote credits are reduced.
48
48
pub const VOTE_CREDITS_MAXIMUM_PER_SLOT : u8 = 16 ;
49
49
50
+ // Previous max per slot
51
+ pub const VOTE_CREDITS_MAXIMUM_PER_SLOT_OLD : u8 = 8 ;
52
+
50
53
#[ frozen_abi( digest = "Ch2vVEwos2EjAVqSHCyJjnN2MNX1yrpapZTGhMSCjWUH" ) ]
51
54
#[ derive( Serialize , Default , Deserialize , Debug , PartialEq , Eq , Clone , AbiExample ) ]
52
55
pub struct Vote {
@@ -597,6 +600,11 @@ impl VoteState {
597
600
. votes
598
601
. get ( index)
599
602
. map_or ( 0 , |landed_vote| landed_vote. latency ) ;
603
+ let max_credits = if deprecate_unused_legacy_vote_plumbing {
604
+ VOTE_CREDITS_MAXIMUM_PER_SLOT
605
+ } else {
606
+ VOTE_CREDITS_MAXIMUM_PER_SLOT_OLD
607
+ } ;
600
608
601
609
// If latency is 0, this means that the Lockout was created and stored from a software version that did not
602
610
// store vote latencies; in this case, 1 credit is awarded
@@ -606,13 +614,13 @@ impl VoteState {
606
614
match latency. checked_sub ( VOTE_CREDITS_GRACE_SLOTS ) {
607
615
None | Some ( 0 ) => {
608
616
// latency was <= VOTE_CREDITS_GRACE_SLOTS, so maximum credits are awarded
609
- VOTE_CREDITS_MAXIMUM_PER_SLOT as u64
617
+ max_credits as u64
610
618
}
611
619
612
620
Some ( diff) => {
613
621
// diff = latency - VOTE_CREDITS_GRACE_SLOTS, and diff > 0
614
622
// Subtract diff from VOTE_CREDITS_MAXIMUM_PER_SLOT which is the number of credits to award
615
- match VOTE_CREDITS_MAXIMUM_PER_SLOT . checked_sub ( diff) {
623
+ match max_credits . checked_sub ( diff) {
616
624
// If diff >= VOTE_CREDITS_MAXIMUM_PER_SLOT, 1 credit is awarded
617
625
None | Some ( 0 ) => 1 ,
618
626
0 commit comments