mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 23:16:48 +00:00
cleanup
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user