coal_api/state/
bus.rs

1use bytemuck::{Pod, Zeroable};
2
3use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};
4
5use super::AccountDiscriminator;
6
7/// Bus accounts are responsible for distributing mining rewards. There are 8 busses total
8/// to minimize write-lock contention and allow Solana to process mine instructions in parallel.
9#[repr(C)]
10#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
11pub struct Bus {
12    /// The ID of the bus account.
13    pub id: u64,
14
15    /// The remaining rewards this bus has left to payout in the current epoch.
16    pub rewards: u64,
17
18    /// The rewards this bus would have paid out in the current epoch if there no limit.
19    /// This is used to calculate the updated reward rate.
20    pub theoretical_rewards: u64,
21
22    /// The largest known stake balance seen by the bus this epoch.
23    pub top_balance: u64,
24}
25
26impl Discriminator for Bus {
27    fn discriminator() -> u8 {
28        AccountDiscriminator::Bus.into()
29    }
30}
31
32impl_to_bytes!(Bus);
33impl_account_from_bytes!(Bus);