account discriminator macro

This commit is contained in:
Hardhat Chad
2024-08-25 14:52:10 +00:00
parent 630b0efd64
commit dce5c11a12
7 changed files with 43 additions and 30 deletions

View File

@@ -1,7 +1,9 @@
use bytemuck::{Pod, Zeroable};
use ore_utils::{account, Discriminator};
use ore_utils::*;
use solana_program::pubkey::Pubkey;
use crate::consts::PROOF;
use super::AccountDiscriminator;
/// Proof accounts track a miner's current hash, claimable rewards, and lifetime stats.
@@ -37,10 +39,9 @@ pub struct Proof {
pub total_rewards: u64,
}
impl Discriminator for Proof {
fn discriminator() -> u8 {
AccountDiscriminator::Proof.into()
}
/// Derive the PDA of a proof account.
pub fn proof_pda(authority: Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(&[PROOF, authority.as_ref()], &crate::id())
}
account!(Proof);
account!(AccountDiscriminator, Proof);