mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-22 23:16:46 +00:00
optimization
This commit is contained in:
@@ -8,12 +8,14 @@ use solana_program::keccak::{Hash as KeccakHash, HASH_BYTES};
|
||||
pub struct Hash(pub [u8; HASH_BYTES]);
|
||||
|
||||
impl From<KeccakHash> for Hash {
|
||||
#[inline(always)]
|
||||
fn from(value: KeccakHash) -> Self {
|
||||
unsafe { transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Hash> for KeccakHash {
|
||||
#[inline(always)]
|
||||
fn from(value: Hash) -> Self {
|
||||
unsafe { transmute(value) }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
mod bus;
|
||||
mod hash;
|
||||
mod proof;
|
||||
mod treasury;
|
||||
|
||||
pub use bus::*;
|
||||
pub use hash::*;
|
||||
pub use proof::*;
|
||||
pub use treasury::*;
|
||||
|
||||
32
src/state/proof.rs
Normal file
32
src/state/proof.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use solana_program::pubkey::Pubkey;
|
||||
|
||||
use super::Hash;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Proof {
|
||||
/// The bump of the proof account PDA.
|
||||
pub bump: u64,
|
||||
|
||||
/// The account (i.e. miner) authorized to use this proof.
|
||||
pub authority: Pubkey,
|
||||
|
||||
/// The quantity of tokens this miner may claim from the treasury.
|
||||
pub claimable_rewards: u64,
|
||||
|
||||
/// The proof's current hash.
|
||||
pub hash: Hash,
|
||||
|
||||
/// The total lifetime hashes provided by this miner.
|
||||
pub total_hashes: u64,
|
||||
|
||||
/// The total lifetime rewards distributed to this miner.
|
||||
pub total_rewards: u64,
|
||||
}
|
||||
|
||||
impl Proof {
|
||||
pub fn to_bytes(&self) -> &[u8] {
|
||||
bytemuck::bytes_of(self)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user