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