instruction macro and simplification

This commit is contained in:
Hardhat Chad
2024-08-26 21:02:52 +00:00
parent 3a3550ced5
commit bff1868ccc
16 changed files with 217 additions and 170 deletions

View File

@@ -4,7 +4,7 @@ use solana_program::pubkey::Pubkey;
use crate::consts::BUS;
use super::AccountDiscriminator;
use super::OreAccount;
/// Bus accounts are responsible for distributing mining rewards. There are 8 busses total
/// to minimize write-lock contention and allow Solana to process mine instructions in parallel.
@@ -26,8 +26,8 @@ pub struct Bus {
}
/// Fetch the PDA of a bus account.
pub fn bus_pda(id: u64) -> (Pubkey, u8) {
Pubkey::find_program_address(&[BUS, id.to_le_bytes().as_slice()], &crate::id())
pub fn bus_pda(id: u8) -> (Pubkey, u8) {
Pubkey::find_program_address(&[BUS, &[id]], &crate::id())
}
account!(AccountDiscriminator, Bus);
account!(OreAccount, Bus);

View File

@@ -4,7 +4,7 @@ use solana_program::pubkey::Pubkey;
use crate::consts::CONFIG;
use super::AccountDiscriminator;
use super::OreAccount;
/// Config is a singleton account which manages program global variables.
#[repr(C)]
@@ -28,4 +28,4 @@ pub fn config_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[CONFIG], &crate::id())
}
account!(AccountDiscriminator, Config);
account!(OreAccount, Config);

View File

@@ -12,7 +12,7 @@ use num_enum::{IntoPrimitive, TryFromPrimitive};
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum AccountDiscriminator {
pub enum OreAccount {
Bus = 100,
Config = 101,
Proof = 102,

View File

@@ -4,7 +4,7 @@ use solana_program::pubkey::Pubkey;
use crate::consts::PROOF;
use super::AccountDiscriminator;
use super::OreAccount;
/// Proof accounts track a miner's current hash, claimable rewards, and lifetime stats.
/// Every miner is allowed one proof account which is required by the program to mine or claim rewards.
@@ -44,4 +44,4 @@ pub fn proof_pda(authority: Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(&[PROOF, authority.as_ref()], &crate::id())
}
account!(AccountDiscriminator, Proof);
account!(OreAccount, Proof);

View File

@@ -4,7 +4,7 @@ use solana_program::pubkey::Pubkey;
use crate::consts::TREASURY;
use super::AccountDiscriminator;
use super::OreAccount;
/// Treasury is a singleton account which is the mint authority for the ORE token and the authority of
/// the program's global token account.
@@ -17,4 +17,4 @@ pub fn treasury_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[TREASURY], &crate::id())
}
account!(AccountDiscriminator, Treasury);
account!(OreAccount, Treasury);