mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 23:16:52 +00:00
last claim at (#120)
This commit is contained in:
@@ -19,11 +19,11 @@ pub struct Proof {
|
||||
/// The last hash the miner provided.
|
||||
pub last_hash: [u8; 32],
|
||||
|
||||
/// The last time this account provided a hash.
|
||||
/// Timestamp of the last time this account provided a hash.
|
||||
pub last_hash_at: i64,
|
||||
|
||||
/// Buffer for possible future use.
|
||||
pub _buffer: [u8; 8],
|
||||
/// Timestamp of the last claim.
|
||||
pub last_claim_at: i64,
|
||||
|
||||
/// The keypair which has permission to submit hashes for mining.
|
||||
pub miner: Pubkey,
|
||||
|
||||
@@ -8,6 +8,7 @@ pub fn process_claim(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
let amount = u64::from_le_bytes(args.amount);
|
||||
|
||||
// Load accounts.
|
||||
let clock = Clock::get()?;
|
||||
let [signer_info, beneficiary_info, proof_info, treasury_info, treasury_tokens_info, token_program] =
|
||||
accounts
|
||||
else {
|
||||
@@ -34,6 +35,9 @@ pub fn process_claim(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
.checked_sub(amount)
|
||||
.ok_or(OreError::ClaimTooLarge)?;
|
||||
|
||||
// Update last claim timestamp.
|
||||
proof.last_claim_at = clock.unix_timestamp;
|
||||
|
||||
// Transfer tokens from treasury to beneficiary.
|
||||
transfer_signed(
|
||||
treasury_info,
|
||||
|
||||
Reference in New Issue
Block a user