challenge

This commit is contained in:
Hardhat Chad
2024-04-28 21:21:37 +00:00
parent 3ecf215151
commit 6d89872752
3 changed files with 5 additions and 5 deletions

View File

@@ -79,7 +79,7 @@ pub fn process_mine<'a, 'info>(
// Calculate the hash from the provided nonce
let noise_data = noise_info.data.borrow();
let hx = drillx::hash(&proof.hash, &args.nonce, &noise_data);
let hx = drillx::hash(&proof.challenge, &args.nonce, &noise_data);
drop(noise_data);
// Validate hash satisfies the minimnum difficulty
@@ -139,7 +139,7 @@ pub fn process_mine<'a, 'info>(
proof.balance = proof.balance.saturating_add(reward);
// Hash recent slot hash into the next challenge to prevent pre-mining attacks
proof.hash = hashv(&[
proof.challenge = hashv(&[
hx.as_slice(),
&slot_hashes_info.data.borrow()[0..size_of::<SlotHash>()],
])

View File

@@ -59,7 +59,7 @@ pub fn process_register<'a, 'info>(
let proof = Proof::try_from_bytes_mut(&mut proof_data)?;
proof.authority = *signer.key;
proof.balance = 0;
proof.hash = hashv(&[
proof.challenge = hashv(&[
signer.key.as_ref(),
&slot_hashes_info.data.borrow()[0..size_of::<SlotHash>()],
])

View File

@@ -18,8 +18,8 @@ pub struct Proof {
/// The quantity of tokens this miner has staked or earned.
pub balance: u64,
/// The proof's current hash.
pub hash: [u8; 32],
/// The current mining challenge.
pub challenge: [u8; 32],
/// The last slot ore was deposited into this account.
pub last_deposit_slot: u64,