marsh_api/state/
bus.rs

1use bytemuck::{Pod, Zeroable};
2use marsh_utils::*;
3use solana_program::pubkey::Pubkey;
4
5use crate::consts::BUS;
6
7use super::MarshAccount;
8
9/// Bus accounts are responsible for distributing mining rewards. There are 8 busses total
10/// to minimize write-lock contention and allow Solana to process mine instructions in parallel.
11/// Every epoch, the bus account rewards counters are topped up to 10 MARSH each (80 MARSH split amongst 8 busses).
12#[repr(C)]
13#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
14pub struct Bus {
15    /// The ID of the bus account.
16    pub id: u64,
17
18    /// The remaining rewards this bus has left to payout in the current epoch.
19    pub rewards: u64,
20
21    /// The rewards this bus would have paid out in the current epoch if there no limit.
22    /// This is used to calculate the updated reward rate.
23    pub theoretical_rewards: u64,
24
25    /// The largest known stake balance seen by the bus this epoch.
26    pub top_balance: u64,
27}
28
29/// Fetch the PDA of a bus account.
30pub fn bus_pda(id: u8) -> (Pubkey, u8) {
31    Pubkey::find_program_address(&[BUS, &[id]], &crate::id())
32}
33
34account!(MarshAccount, Bus);