#[repr(C)]pub struct Ledger {Show 14 fields
pub authority: Pubkey,
pub tickets: u64,
pub unstaked_micros: u64,
pub win_streak: u64,
pub last_win_period: u64,
pub last_win_series_id: u16,
pub _pad0: [u8; 6],
pub total_wins: u64,
pub total_bets: u64,
pub peak_win_streak: u64,
pub week_wins: u64,
pub week_bets: u64,
pub week_peak_streak: u64,
pub week_number: u64,
}Fields§
§tickets: u64Whole tickets credited on BuyTickets; debited on PlaceBet.
unstaked_micros: u64Post-team-cut USDC micros mirroring tickets (1 ticket = TICKET_MICROS µ).
win_streak: u64Consecutive wins on [last_win_series_id] with period + 1 steps.
last_win_period: u64Last Market::period confirmed as a win (via ExecutorTreasury distribute). 0 = none.
last_win_series_id: u16series_id for [last_win_period] (streak concurrency key).
_pad0: [u8; 6]§total_wins: u64Total rounds on the winning side (all-time correct calls).
total_bets: u64Total ticket-debit events across all PlaceBet calls (each stake spend = +1).
peak_win_streak: u64All-time highest win_streak ever recorded for this player.
week_wins: u64Wins in the current executor week.
week_bets: u64Bets placed in the current executor week.
week_peak_streak: u64Longest streak achieved in the current executor week.
week_number: u64Which executor week these week_* stats belong to. Compared against
Treasury::current_week; if stale, zero weekly fields and update this.
Implementations§
Source§impl Ledger
impl Ledger
pub fn pda(authority: Pubkey) -> (Pubkey, u8)
Sourcepub fn maybe_reset_weekly(&mut self, current_week: u64)
pub fn maybe_reset_weekly(&mut self, current_week: u64)
Reset weekly counters if the executor has advanced [Treasury::current_week].
Call at the top of any code path that reads or writes weekly stats, passing the
value read from Treasury::current_week.
Sourcepub fn record_win(
&mut self,
market_period: u64,
series_id: u16,
current_week: u64,
)
pub fn record_win( &mut self, market_period: u64, series_id: u16, current_week: u64, )
Record a confirmed win for this player. Called from ExecutorTreasury (distribute).
Updates streak, peak streak, total wins, and weekly equivalents.
current_week must be read from Treasury::current_week before calling.
Sourcepub fn record_loss(&mut self, current_week: u64)
pub fn record_loss(&mut self, current_week: u64)
Record a loss (streak break). Called from PlaceBet when the previous period is settled
as a loss for this player.
current_week must be read from Treasury::current_week before calling.
Sourcepub fn record_bet(&mut self, current_week: u64)
pub fn record_bet(&mut self, current_week: u64)
Record a bet (ticket debit). Called from PlaceBet whenever tickets are actually spent.
current_week must be read from Treasury::current_week before calling.
Trait Implementations§
Source§impl AccountValidation for Ledger
impl AccountValidation for Ledger
fn assert<F>(&self, condition: F) -> Result<&Self, ProgramError>
fn assert_err<F>( &self, condition: F, err: ProgramError, ) -> Result<&Self, ProgramError>
fn assert_msg<F>(&self, condition: F, msg: &str) -> Result<&Self, ProgramError>
fn assert_mut<F>(&mut self, condition: F) -> Result<&mut Self, ProgramError>
fn assert_mut_err<F>( &mut self, condition: F, err: ProgramError, ) -> Result<&mut Self, ProgramError>
fn assert_mut_msg<F>( &mut self, condition: F, msg: &str, ) -> Result<&mut Self, ProgramError>
Source§impl Discriminator for Ledger
impl Discriminator for Ledger
fn discriminator() -> u8
impl Copy for Ledger
impl Pod for Ledger
impl StructuralPartialEq for Ledger
Auto Trait Implementations§
impl Freeze for Ledger
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnsafeUnpin for Ledger
impl UnwindSafe for Ledger
Blanket Implementations§
Source§impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
fn try_from_bytes(data: &[u8]) -> Result<&T, ProgramError>
fn try_from_bytes_mut(data: &mut [u8]) -> Result<&mut T, ProgramError>
Source§impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
fn try_header_from_bytes(data: &[u8]) -> Result<(&T, &[u8]), ProgramError>
fn try_header_from_bytes_mut( data: &mut [u8], ) -> Result<(&mut T, &mut [u8]), ProgramError>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more