mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-19 15:10:29 +00:00
continued refactor
This commit is contained in:
@@ -8,6 +8,8 @@ use solana_program::{
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
||||
pub(crate) use utils;
|
||||
|
||||
#[cfg(not(feature = "no-entrypoint"))]
|
||||
solana_program::entrypoint!(process_instruction);
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use ore_api::{
|
||||
consts::*,
|
||||
state::{Bus, Config, Proof, Treasury},
|
||||
utils::{AccountDeserialize, Discriminator},
|
||||
};
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, program_error::ProgramError, program_pack::Pack, pubkey::Pubkey,
|
||||
@@ -9,6 +8,8 @@ use solana_program::{
|
||||
};
|
||||
use spl_token::state::Mint;
|
||||
|
||||
use crate::utils::{AccountDeserialize, Discriminator};
|
||||
|
||||
/// Errors if:
|
||||
/// - Account is not a signer.
|
||||
pub fn load_signer<'a, 'info>(info: &'a AccountInfo<'info>) -> Result<(), ProgramError> {
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
use ore_api::{
|
||||
consts::*, error::OreError, instruction::ClaimArgs, state::Proof, utils::AccountDeserialize,
|
||||
};
|
||||
use ore_api::{consts::*, error::OreError, instruction::ClaimArgs, state::Proof};
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
||||
use crate::loaders::*;
|
||||
use crate::{loaders::*, utils::AccountDeserialize};
|
||||
|
||||
/// Claim distributes Ore from the treasury to a miner. Its responsibilies include:
|
||||
/// 1. Decrement the miner's claimable balance.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use ore_api::{state::Proof, utils::AccountDeserialize};
|
||||
use ore_api::state::Proof;
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
|
||||
pubkey::Pubkey, system_program,
|
||||
};
|
||||
|
||||
use crate::loaders::*;
|
||||
use crate::{loaders::*, utils::AccountDeserialize};
|
||||
|
||||
/// Close closes a proof account and returns the rent to the owner. Its responsibilities include:
|
||||
/// 1. Realloc proof account size to 0.
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
use ore_api::{
|
||||
state::{Config, Proof},
|
||||
utils::AccountDeserialize,
|
||||
};
|
||||
use ore_api::state::{Config, Proof};
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
||||
use crate::loaders::*;
|
||||
use crate::{loaders::*, utils::AccountDeserialize};
|
||||
|
||||
/// Crown flags an account as the top staker if their balance is greater than the last known top staker.
|
||||
pub fn process_crown<'a, 'info>(
|
||||
|
||||
@@ -4,9 +4,6 @@ use ore_api::{
|
||||
consts::*,
|
||||
instruction::*,
|
||||
state::{Bus, Config, Treasury},
|
||||
utils::create_pda,
|
||||
utils::AccountDeserialize,
|
||||
utils::Discriminator,
|
||||
};
|
||||
use solana_program::{
|
||||
account_info::AccountInfo,
|
||||
@@ -18,7 +15,10 @@ use solana_program::{
|
||||
};
|
||||
use spl_token::state::Mint;
|
||||
|
||||
use crate::loaders::*;
|
||||
use crate::{
|
||||
loaders::*,
|
||||
utils::{create_pda, AccountDeserialize, Discriminator},
|
||||
};
|
||||
|
||||
/// Initialize sets up the Ore program. Its responsibilities include:
|
||||
/// 1. Initialize the 8 bus accounts.
|
||||
|
||||
@@ -4,9 +4,9 @@ use drillx::Solution;
|
||||
use ore_api::{
|
||||
consts::*,
|
||||
error::OreError,
|
||||
event::MineEvent,
|
||||
instruction::{MineArgs, OreInstruction},
|
||||
state::{Bus, Config, Proof},
|
||||
utils::{AccountDeserialize, MineEvent},
|
||||
};
|
||||
use solana_program::program::set_return_data;
|
||||
#[allow(deprecated)]
|
||||
@@ -25,7 +25,7 @@ use solana_program::{
|
||||
sysvar::{self, instructions::load_current_index, Sysvar},
|
||||
};
|
||||
|
||||
use crate::loaders::*;
|
||||
use crate::{loaders::*, utils::AccountDeserialize};
|
||||
|
||||
/// Mine is the primary workhorse instruction of the Ore program. Its responsibilities include:
|
||||
/// 1. Calculate the hash from the provided nonce.
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
use std::mem::size_of;
|
||||
|
||||
use ore_api::{
|
||||
consts::*,
|
||||
instruction::OpenArgs,
|
||||
state::Proof,
|
||||
utils::{create_pda, AccountDeserialize, Discriminator},
|
||||
};
|
||||
use ore_api::{consts::*, instruction::OpenArgs, state::Proof};
|
||||
use solana_program::{
|
||||
account_info::AccountInfo,
|
||||
blake3::hashv,
|
||||
@@ -18,7 +13,10 @@ use solana_program::{
|
||||
sysvar::{self, Sysvar},
|
||||
};
|
||||
|
||||
use crate::loaders::*;
|
||||
use crate::{
|
||||
loaders::*,
|
||||
utils::{create_pda, AccountDeserialize, Discriminator},
|
||||
};
|
||||
|
||||
/// Register generates a new hash chain for a prospective miner. Its responsibilities include:
|
||||
/// 1. Initialize a new proof account.
|
||||
|
||||
@@ -2,7 +2,6 @@ use ore_api::{
|
||||
consts::*,
|
||||
error::OreError,
|
||||
state::{Bus, Config},
|
||||
utils::AccountDeserialize,
|
||||
};
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, clock::Clock, entrypoint::ProgramResult,
|
||||
@@ -10,8 +9,12 @@ use solana_program::{
|
||||
};
|
||||
use spl_token::state::Mint;
|
||||
|
||||
use crate::loaders::{
|
||||
load_bus, load_config, load_mint, load_program, load_signer, load_token_account, load_treasury,
|
||||
use crate::{
|
||||
loaders::{
|
||||
load_bus, load_config, load_mint, load_program, load_signer, load_token_account,
|
||||
load_treasury,
|
||||
},
|
||||
utils::AccountDeserialize,
|
||||
};
|
||||
|
||||
/// Reset sets up the Ore program for the next epoch. Its responsibilities include:
|
||||
@@ -165,9 +168,9 @@ pub(crate) fn calculate_new_reward_rate(current_rate: u64, epoch_rewards: u64) -
|
||||
mod tests {
|
||||
use rand::{distributions::Uniform, Rng};
|
||||
|
||||
use crate::{
|
||||
calculate_new_reward_rate, BUS_EPOCH_REWARDS, MAX_EPOCH_REWARDS, SMOOTHING_FACTOR,
|
||||
TARGET_EPOCH_REWARDS,
|
||||
use crate::calculate_new_reward_rate;
|
||||
use ore_api::consts::{
|
||||
BUS_EPOCH_REWARDS, MAX_EPOCH_REWARDS, SMOOTHING_FACTOR, TARGET_EPOCH_REWARDS,
|
||||
};
|
||||
|
||||
const FUZZ_SIZE: u64 = 10_000;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use ore_api::{consts::*, instruction::StakeArgs, state::Proof, utils::AccountDeserialize};
|
||||
use ore_api::{consts::*, instruction::StakeArgs, state::Proof};
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, clock::Clock, entrypoint::ProgramResult,
|
||||
program_error::ProgramError, pubkey::Pubkey, sysvar::Sysvar,
|
||||
};
|
||||
|
||||
use crate::loaders::*;
|
||||
use crate::{loaders::*, utils::AccountDeserialize};
|
||||
|
||||
/// Stake deposits Ore into a miner's proof account to earn multiplier. Its responsibilies include:
|
||||
/// 1. Transfer tokens from the miner to the treasury account.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use ore_api::{state::Proof, utils::AccountDeserialize};
|
||||
use ore_api::state::Proof;
|
||||
use solana_program::{
|
||||
account_info::AccountInfo, entrypoint::ProgramResult, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
};
|
||||
|
||||
use crate::loaders::*;
|
||||
use crate::{loaders::*, utils::AccountDeserialize};
|
||||
|
||||
/// Update changes the miner authority on a proof account.
|
||||
pub fn process_update<'a, 'info>(
|
||||
|
||||
Reference in New Issue
Block a user