#[repr(C)]pub struct Refinery {
pub total_network_mining_power: u64,
pub emission_per_block: u64,
pub last_emission_update_block: u64,
pub rig_supplies: [u64; 15],
pub rig_current: [u64; 15],
pub rig_configs: [RigConfig; 15],
pub admin: Pubkey,
pub refinery_rewards_factor: Numeric,
pub last_rewards_factor_block: u64,
pub buffer_a: u64,
pub buffer_b: u64,
}Expand description
Refinery global state (singleton account)
Fields§
§total_network_mining_power: u64Sum of all players’ Mining Power
emission_per_block: u64Current emission rate per block (in atomic units with 11 decimals)
last_emission_update_block: u64Block when emission rate was last updated (tracks initialization time for day calculation)
rig_supplies: [u64; 15]Max supply per rig type (u64::MAX = unlimited, otherwise the max supply)
rig_current: [u64; 15]Current supply per rig type (number minted)
rig_configs: [RigConfig; 15]Stats configuration for each rig type (0-14)
admin: PubkeyAdmin authority that can update rig_configs
refinery_rewards_factor: NumericCumulative reward per unit of mining power (updated when advancing emission; used for claim math)
last_rewards_factor_block: u64Block through which refinery_rewards_factor has been applied (for lazy updates)
buffer_a: u64Buffer field (for future extensions)
buffer_b: u64Buffer field (for future extensions)
Implementations§
Source§impl Refinery
impl Refinery
pub fn pda() -> (Pubkey, u8)
pub fn initialize( &mut self, admin: Pubkey, clock: &Clock, initial_emission: u64, )
Sourcepub fn update_emission_rate(&mut self, clock: &Clock, blocks_per_day: u64)
pub fn update_emission_rate(&mut self, clock: &Clock, blocks_per_day: u64)
Update emission rate based on days elapsed (growth/decreasing phase)
Sourcepub fn can_mint_rig(&self, rig_type: u64) -> bool
pub fn can_mint_rig(&self, rig_type: u64) -> bool
Check if rig can be minted (supply limit check)
Sourcepub fn increment_rig_supply(&mut self, rig_type: u64)
pub fn increment_rig_supply(&mut self, rig_type: u64)
Increment rig supply after minting
Sourcepub fn update_mining_power(&mut self, mining_power_change: i64)
pub fn update_mining_power(&mut self, mining_power_change: i64)
Update mining power when rig is placed/removed
Sourcepub fn advance_rewards_factor(&mut self, clock: &Clock)
pub fn advance_rewards_factor(&mut self, clock: &Clock)
Advance refinery_rewards_factor up to current block (call before claim or when reading claimable). Claimable for a plot = plot.total_mining_power * (refinery.rewards_factor - plot.last_refinery_rewards_factor).
Trait Implementations§
Source§impl AccountValidation for Refinery
impl AccountValidation for Refinery
fn assert<F>(&self, condition: F) -> Result<&Self, ProgramError>
fn assert_err<F>( &self, condition: F, err: ProgramError, ) -> Result<&Self, ProgramError>
fn assert_msg<F>(&self, condition: F, msg: &str) -> Result<&Self, ProgramError>
fn assert_mut<F>(&mut self, condition: F) -> Result<&mut Self, ProgramError>
fn assert_mut_err<F>( &mut self, condition: F, err: ProgramError, ) -> Result<&mut Self, ProgramError>
fn assert_mut_msg<F>( &mut self, condition: F, msg: &str, ) -> Result<&mut Self, ProgramError>
Source§impl<'de> Deserialize<'de> for Refinery
impl<'de> Deserialize<'de> for Refinery
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Discriminator for Refinery
impl Discriminator for Refinery
fn discriminator() -> u8
impl Copy for Refinery
impl Pod for Refinery
impl StructuralPartialEq for Refinery
Auto Trait Implementations§
impl Freeze for Refinery
impl RefUnwindSafe for Refinery
impl Send for Refinery
impl Sync for Refinery
impl Unpin for Refinery
impl UnsafeUnpin for Refinery
impl UnwindSafe for Refinery
Blanket Implementations§
Source§impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountDeserialize for Twhere
T: Discriminator + Pod,
fn try_from_bytes(data: &[u8]) -> Result<&T, ProgramError>
fn try_from_bytes_mut(data: &mut [u8]) -> Result<&mut T, ProgramError>
Source§impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
impl<T> AccountHeaderDeserialize for Twhere
T: Discriminator + Pod,
fn try_header_from_bytes(data: &[u8]) -> Result<(&T, &[u8]), ProgramError>
fn try_header_from_bytes_mut( data: &mut [u8], ) -> Result<(&mut T, &mut [u8]), ProgramError>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more