coal_api/state/
config.rs

1use bytemuck::{Pod, Zeroable};
2
3use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};
4
5use super::AccountDiscriminator;
6
7/// Config is a singleton account which manages program coal minting variables.
8#[repr(C)]
9#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
10pub struct Config {
11    /// The base reward rate paid out for a hash of minimum difficulty.
12    pub base_reward_rate: u64,
13
14    /// The timestamp of the last reset.
15    pub last_reset_at: i64,
16
17    /// The minimum accepted difficulty.
18    pub min_difficulty: u64,
19
20    /// The largest known stake balance on the network from the last epoch.
21    pub top_balance: u64,
22}
23
24impl Discriminator for Config {
25    fn discriminator() -> u8 {
26        AccountDiscriminator::Config.into()
27    }
28}
29
30/// Config is a singleton account which manages program coal minting variables.
31#[repr(C)]
32#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
33pub struct WoodConfig {
34    /// The base reward rate paid out for a hash of minimum difficulty.
35    pub base_reward_rate: u64,
36
37    /// The timestamp of the last reset.
38    pub last_reset_at: i64,
39
40    /// The minimum accepted difficulty.
41    pub min_difficulty: u64,
42
43    /// The largest known stake balance on the network from the last epoch.
44    pub top_balance: u64,
45
46    /// The current epoch emission rate for the program.
47    pub total_epoch_rewards: u64,
48}
49
50impl Discriminator for WoodConfig {
51    fn discriminator() -> u8 {
52        AccountDiscriminator::WoodConfig.into()
53    }
54}
55
56impl_to_bytes!(Config);
57impl_account_from_bytes!(Config);
58impl_to_bytes!(WoodConfig);
59impl_account_from_bytes!(WoodConfig);