mars/state/
proof.rs

1use bytemuck::{Pod, Zeroable};
2use shank::ShankAccount;
3use solana_program::pubkey::Pubkey;
4
5use crate::{
6    impl_account_from_bytes, impl_to_bytes,
7    state::Hash,
8    utils::{AccountDiscriminator, Discriminator},
9};
10
11/// Proof accounts track a miner's current hash, claimable rewards, and lifetime stats.
12/// Every miner is allowed one proof account which is required by the program to mine or claim rewards.
13#[repr(C)]
14#[derive(Clone, Copy, Debug, PartialEq, Pod, ShankAccount, Zeroable)]
15pub struct Proof {
16    /// The account (i.e. miner) authorized to use this proof.
17    pub authority: Pubkey,
18
19    /// The quantity of tokens this miner may claim from the treasury.
20    pub claimable_rewards: u64,
21
22    /// The proof's current hash.
23    pub hash: Hash,
24
25    /// The total lifetime hashes provided by this miner.
26    pub total_hashes: u64,
27
28    /// The total lifetime rewards distributed to this miner.
29    pub total_rewards: u64,
30}
31
32impl Discriminator for Proof {
33    fn discriminator() -> AccountDiscriminator {
34        AccountDiscriminator::Proof
35    }
36}
37
38impl_to_bytes!(Proof);
39impl_account_from_bytes!(Proof);