mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-19 15:10:29 +00:00
last hash
This commit is contained in:
@@ -54,9 +54,6 @@ pub fn process_claim<'a, 'info>(
|
||||
.checked_sub(amount)
|
||||
.ok_or(OreError::ClaimTooLarge)?;
|
||||
|
||||
// Update timestamp
|
||||
proof.last_claim_at = clock.unix_timestamp;
|
||||
|
||||
// Distribute tokens from treasury to beneficiary
|
||||
solana_program::program::invoke_signed(
|
||||
&spl_token::instruction::transfer(
|
||||
|
||||
@@ -169,6 +169,7 @@ pub fn process_mine<'a, 'info>(
|
||||
proof.balance = proof.balance.saturating_add(reward_actual);
|
||||
|
||||
// Hash recent slot hash into the next challenge to prevent pre-mining attacks
|
||||
proof.last_hash = hash.h;
|
||||
proof.challenge = hashv(&[
|
||||
hash.h.as_slice(),
|
||||
&slot_hashes_sysvar.data.borrow()[0..size_of::<SlotHash>()],
|
||||
|
||||
@@ -72,7 +72,7 @@ pub fn process_register<'a, 'info>(
|
||||
&slot_hashes_info.data.borrow()[0..size_of::<SlotHash>()],
|
||||
])
|
||||
.0;
|
||||
proof.last_claim_at = clock.unix_timestamp;
|
||||
proof.last_hash = [0; 32];
|
||||
proof.last_hash_at = clock.unix_timestamp;
|
||||
proof.last_stake_at = clock.unix_timestamp;
|
||||
proof.total_hashes = 0;
|
||||
|
||||
@@ -21,8 +21,8 @@ pub struct Proof {
|
||||
/// The current mining challenge.
|
||||
pub challenge: [u8; 32],
|
||||
|
||||
/// The last time this account claimed rewards.
|
||||
pub last_claim_at: i64,
|
||||
/// The last hash the miner provided.
|
||||
pub last_hash: [u8; 32],
|
||||
|
||||
/// The last time this account provided a hash.
|
||||
pub last_hash_at: i64,
|
||||
|
||||
Reference in New Issue
Block a user