mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-17 07:26:52 +00:00
mine v2
This commit is contained in:
@@ -17,12 +17,6 @@ pub struct Bus {
|
||||
|
||||
/// The quantity of rewards this bus can issue in the current epoch epoch.
|
||||
pub rewards: u64,
|
||||
|
||||
/// Histogram of hash count per difficulty
|
||||
pub hash_hist: [u64; 32],
|
||||
|
||||
/// Cumulative sum of applied multipliers per difficulty
|
||||
pub multiplier_hist: [u64; 32],
|
||||
}
|
||||
|
||||
impl Discriminator for Bus {
|
||||
|
||||
@@ -2,9 +2,10 @@ use bytemuck::{Pod, Zeroable};
|
||||
use shank::ShankAccount;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
|
||||
// TODO next_min_difficulty: Option<u8>, update on reset
|
||||
|
||||
use crate::{
|
||||
impl_account_from_bytes, impl_to_bytes,
|
||||
state::Hash,
|
||||
utils::{AccountDiscriminator, Discriminator},
|
||||
};
|
||||
|
||||
@@ -15,8 +16,14 @@ pub struct Config {
|
||||
/// The admin authority with permission to update the difficulty.
|
||||
pub admin: Pubkey,
|
||||
|
||||
/// The hash difficulty.
|
||||
pub difficulty: Hash,
|
||||
/// The base reward rate paid out for a hash of minimum difficulty.
|
||||
pub base_reward_rate: u64,
|
||||
|
||||
/// The minimum accepted difficulty.
|
||||
pub min_difficulty: u32,
|
||||
|
||||
/// Is mining paused.
|
||||
pub paused: u32,
|
||||
}
|
||||
|
||||
impl Discriminator for Config {
|
||||
|
||||
@@ -30,4 +30,18 @@ impl fmt::Display for Hash {
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash {
|
||||
pub fn difficulty(&self) -> u32 {
|
||||
let mut count = 0;
|
||||
for &byte in &self.0 {
|
||||
let lz = byte.leading_zeros();
|
||||
count += lz;
|
||||
if lz < 8 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
count
|
||||
}
|
||||
}
|
||||
|
||||
impl_to_bytes!(Hash);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
mod bus;
|
||||
mod config;
|
||||
mod hash;
|
||||
// mod hash;
|
||||
mod proof;
|
||||
mod treasury;
|
||||
|
||||
pub use bus::*;
|
||||
pub use config::*;
|
||||
pub use hash::*;
|
||||
// pub use hash::*;
|
||||
pub use proof::*;
|
||||
pub use treasury::*;
|
||||
|
||||
@@ -4,7 +4,6 @@ use solana_program::pubkey::Pubkey;
|
||||
|
||||
use crate::{
|
||||
impl_account_from_bytes, impl_to_bytes,
|
||||
state::Hash,
|
||||
utils::{AccountDiscriminator, Discriminator},
|
||||
};
|
||||
|
||||
@@ -16,18 +15,17 @@ pub struct Proof {
|
||||
/// The signer authorized to use this proof.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The quantity of tokens this miner may claim from the treasury.
|
||||
/// The quantity of tokens this miner has staked or earned.
|
||||
pub balance: u64,
|
||||
|
||||
/// The proof's current hash.
|
||||
pub hash: Hash,
|
||||
pub hash: [u8; 32],
|
||||
|
||||
/// The last slot ore was deposited into this account.
|
||||
pub last_deposit_slot: u64,
|
||||
|
||||
/// The last time this account provided a hash.
|
||||
pub last_hash_at: u64,
|
||||
|
||||
// TODO Figure out multiplier representation
|
||||
/// The rewards multiplier for this account.
|
||||
pub multiplier: u64,
|
||||
pub last_hash_at: i64,
|
||||
|
||||
/// The total lifetime hashes provided by this miner.
|
||||
pub total_hashes: u64,
|
||||
|
||||
@@ -14,12 +14,6 @@ pub struct Treasury {
|
||||
/// The bump of the treasury account PDA, for signing CPIs.
|
||||
pub bump: u64,
|
||||
|
||||
/// The timestamp of the reset invocation.
|
||||
pub last_reset_at: i64,
|
||||
|
||||
/// The reward rate to payout to miners for submiting valid hashes.
|
||||
pub reward_rate: u64,
|
||||
|
||||
/// The total lifetime claimed rewards of the program.
|
||||
pub total_claimed_rewards: u64,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user