last hash

This commit is contained in:
Hardhat Chad
2024-05-23 03:41:30 +00:00
parent e13a5bd889
commit 465643c2c9
4 changed files with 4 additions and 6 deletions

View File

@@ -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(

View File

@@ -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>()],

View File

@@ -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;

View File

@@ -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,