mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-19 07:26:47 +00:00
initialize
This commit is contained in:
20
src/state/bus.rs
Normal file
20
src/state/bus.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Bus {
|
||||
/// The bump of the bus account PDA.
|
||||
pub bump: u32,
|
||||
|
||||
/// The ID of the bus account.
|
||||
pub id: u32,
|
||||
|
||||
/// The quantity of rewards this bus can issue in the current epoch epoch.
|
||||
pub available_rewards: u64,
|
||||
}
|
||||
|
||||
impl Bus {
|
||||
pub fn to_bytes(&self) -> &[u8] {
|
||||
bytemuck::bytes_of(self)
|
||||
}
|
||||
}
|
||||
20
src/state/hash.rs
Normal file
20
src/state/hash.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
use std::mem::transmute;
|
||||
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use solana_program::keccak::{Hash as KeccakHash, HASH_BYTES};
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Hash(pub [u8; HASH_BYTES]);
|
||||
|
||||
impl From<KeccakHash> for Hash {
|
||||
fn from(value: KeccakHash) -> Self {
|
||||
unsafe { transmute(value) }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Hash> for KeccakHash {
|
||||
fn from(value: Hash) -> Self {
|
||||
unsafe { transmute(value) }
|
||||
}
|
||||
}
|
||||
7
src/state/mod.rs
Normal file
7
src/state/mod.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
mod bus;
|
||||
mod hash;
|
||||
mod treasury;
|
||||
|
||||
pub use bus::*;
|
||||
pub use hash::*;
|
||||
pub use treasury::*;
|
||||
32
src/state/treasury.rs
Normal file
32
src/state/treasury.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 Treasury {
|
||||
/// The bump of the treasury account PDA.
|
||||
pub bump: u64,
|
||||
|
||||
/// The admin authority with permission to update the difficulty.
|
||||
pub admin: Pubkey,
|
||||
|
||||
/// The hash difficulty.
|
||||
pub difficulty: Hash,
|
||||
|
||||
/// The timestamp of the start of the current epoch.
|
||||
pub epoch_start_at: i64,
|
||||
|
||||
/// The reward rate to payout to miners for submiting valid hashes.
|
||||
pub reward_rate: u64,
|
||||
|
||||
/// The total lifetime claimed rewards.
|
||||
pub total_claimed_rewards: u64,
|
||||
}
|
||||
|
||||
impl Treasury {
|
||||
pub fn to_bytes(&self) -> &[u8] {
|
||||
bytemuck::bytes_of(self)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user