coal_api/state/
proof.rs

1use bytemuck::{Pod, Zeroable};
2use solana_program::pubkey::Pubkey;
3
4use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};
5
6use super::AccountDiscriminator;
7
8/// Proof accounts track a miner's current hash, claimable rewards, and lifetime stats.
9/// Every miner is allowed one proof account which is required by the program to mine or claim rewards.
10#[repr(C)]
11#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
12pub struct Proof {
13    /// The signer authorized to use this proof.
14    pub authority: Pubkey,
15
16    /// The quantity of tokens this miner has staked or earned.
17    pub balance: u64,
18
19    /// The current mining challenge.
20    pub challenge: [u8; 32],
21
22    /// The last hash the miner provided.
23    pub last_hash: [u8; 32],
24
25    /// The last time this account provided a hash.
26    pub last_hash_at: i64,
27
28    /// The last time stake was deposited into this account.
29    pub last_stake_at: i64,
30
31    /// The keypair which has permission to submit hashes for mining.
32    pub miner: Pubkey,
33
34    /// The total lifetime hashes provided by this miner.
35    pub total_hashes: u64,
36
37    /// The total lifetime rewards distributed to this miner.
38    pub total_rewards: u64,
39}
40
41impl Discriminator for Proof {
42    fn discriminator() -> u8 {
43        AccountDiscriminator::Proof.into()
44    }
45}
46
47impl_to_bytes!(Proof);
48impl_account_from_bytes!(Proof);