mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
cleanup
This commit is contained in:
@@ -17,12 +17,14 @@ pub enum OreError {
|
||||
ClaimTooLarge = 4,
|
||||
#[error("The clock time is invalid")]
|
||||
ClockInvalid = 5,
|
||||
#[error("You are trying to submit too soon")]
|
||||
Spam = 6,
|
||||
#[error("Only one hash may be validated per transaction")]
|
||||
TransactionInvalid = 6,
|
||||
TransactionInvalid = 7,
|
||||
#[error("The tolerance cannot exceed i64 max value")]
|
||||
ToleranceOverflow = 7,
|
||||
ToleranceOverflow = 8,
|
||||
#[error("The maximum supply has been reached")]
|
||||
MaxSupply = 8,
|
||||
MaxSupply = 9,
|
||||
}
|
||||
|
||||
impl From<OreError> for ProgramError {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
pub mod consts;
|
||||
pub mod error;
|
||||
pub mod instruction;
|
||||
mod loaders;
|
||||
pub mod loaders;
|
||||
mod processor;
|
||||
pub mod state;
|
||||
pub mod utils;
|
||||
@@ -14,9 +14,6 @@ use solana_program::{
|
||||
program_error::ProgramError, pubkey::Pubkey,
|
||||
};
|
||||
|
||||
// TODO Initialize with mining paused
|
||||
// TODO Require hardcoded admin key for initialization
|
||||
|
||||
declare_id!("mineQW6HcBby3YyZMTaRRtuFWPaGEg8AjmCAWs4nBU8");
|
||||
|
||||
#[cfg(not(feature = "no-entrypoint"))]
|
||||
|
||||
@@ -5,6 +5,7 @@ use solana_program::{
|
||||
entrypoint::ProgramResult,
|
||||
program_error::ProgramError,
|
||||
program_pack::Pack,
|
||||
pubkey,
|
||||
pubkey::Pubkey,
|
||||
system_program, {self, sysvar},
|
||||
};
|
||||
@@ -21,6 +22,9 @@ use crate::{
|
||||
METADATA_SYMBOL, METADATA_URI, MINT, MINT_ADDRESS, MINT_NOISE, TOKEN_DECIMALS, TREASURY,
|
||||
};
|
||||
|
||||
/// The address to allow for initialization.
|
||||
const AUTHORIZED_INITIALIZER: Pubkey = pubkey!("HBUh9g46wk2X89CvaNN15UmsznP59rh6od1h8JwYAopk");
|
||||
|
||||
/// Initialize sets up the Ore program. Its responsibilities include:
|
||||
/// 1. Initialize the 8 bus accounts.
|
||||
/// 2. Initialize the treasury account.
|
||||
@@ -87,6 +91,11 @@ pub fn process_initialize<'a, 'info>(
|
||||
load_program(metadata_program, mpl_token_metadata::ID)?;
|
||||
load_sysvar(rent_sysvar, sysvar::rent::id())?;
|
||||
|
||||
// Check signer
|
||||
if signer.key.ne(&AUTHORIZED_INITIALIZER) {
|
||||
return Err(ProgramError::MissingRequiredSignature);
|
||||
}
|
||||
|
||||
// Initialize bus accounts
|
||||
let bus_infos = [
|
||||
bus_0_info, bus_1_info, bus_2_info, bus_3_info, bus_4_info, bus_5_info, bus_6_info,
|
||||
@@ -133,7 +142,7 @@ pub fn process_initialize<'a, 'info>(
|
||||
config.admin = *signer.key;
|
||||
config.base_reward_rate = INITIAL_BASE_REWARD_RATE;
|
||||
config.last_reset_at = 0;
|
||||
config.paused = 0;
|
||||
config.paused = 1;
|
||||
config.tolerance_liveness = INITIAL_TOLERANCE;
|
||||
config.tolerance_spam = INITIAL_TOLERANCE;
|
||||
|
||||
|
||||
@@ -7,14 +7,15 @@ use solana_program::{
|
||||
blake3::hashv,
|
||||
clock::Clock,
|
||||
entrypoint::ProgramResult,
|
||||
log::sol_log,
|
||||
program_error::ProgramError,
|
||||
pubkey,
|
||||
pubkey::Pubkey,
|
||||
sanitize::SanitizeError,
|
||||
serialize_utils::{read_pubkey, read_u16, read_u8},
|
||||
slot_hashes::SlotHash,
|
||||
sysvar::{self, instructions::load_current_index, Sysvar},
|
||||
};
|
||||
use solana_program::{log::sol_log, pubkey};
|
||||
|
||||
use crate::{
|
||||
error::OreError,
|
||||
@@ -134,8 +135,8 @@ pub fn process_mine<'a, 'info>(
|
||||
let t_target = proof.last_hash_at.saturating_add(ONE_MINUTE);
|
||||
let t_spam = t_target.saturating_sub(config.tolerance_spam);
|
||||
if t.lt(&t_spam) {
|
||||
reward = 0;
|
||||
sol_log("Spam penalty");
|
||||
return Err(OreError::Spam.into());
|
||||
}
|
||||
|
||||
// Apply liveness penalty
|
||||
|
||||
@@ -15,7 +15,7 @@ pub struct Bus {
|
||||
/// The ID of the bus account.
|
||||
pub id: u64,
|
||||
|
||||
/// The remaining rewards this bus has left to payout in the current epoch epoch.
|
||||
/// The remaining rewards this bus has left to payout in the current epoch.
|
||||
pub rewards: u64,
|
||||
|
||||
/// The rewards this bus would have paid out in the current epoch if there no limit.
|
||||
|
||||
Reference in New Issue
Block a user