update mine event

This commit is contained in:
Hardhat Chad
2025-07-15 18:03:05 -07:00
parent 4a3f61bc71
commit 3e30ebb87d
2 changed files with 14 additions and 9 deletions

View File

@@ -105,6 +105,9 @@ pub struct MineEvent {
/// The total amount of hashes deployed in the block.
pub total_deployed: u64,
/// The amount of hashpower remaining in the permit.
pub remaining_commitment: u64,
/// The timestamp of the event.
pub ts: i64,
}

View File

@@ -53,12 +53,13 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
permit.commitment -= amount;
// Pay executor fee.
if permit.fee > 0 {
permit_info.send(permit.fee * amount, signer_info);
}
// if permit.fee > 0 {
// permit_info.send(permit.fee * amount, signer_info);
// }
// Close permit account, if empty.
if permit.commitment == 0 {
let permit_commitment = permit.commitment;
if permit_commitment == 0 {
permit_info.close(authority_info)?;
}
@@ -86,11 +87,11 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
// Reset miner hash if mining new block.
if miner.block_id != block.id {
let mut args = [0u8; 128];
args[..32].copy_from_slice(&block.id.to_le_bytes());
args[32..64].copy_from_slice(&block.slot_hash);
args[64..96].copy_from_slice(&permit.authority.to_bytes());
args[96..].copy_from_slice(&permit.seed);
let mut args = [0u8; 104];
args[..8].copy_from_slice(&block.id.to_le_bytes());
args[8..40].copy_from_slice(&block.slot_hash);
args[40..72].copy_from_slice(&permit.authority.to_bytes());
args[72..].copy_from_slice(&permit.seed);
miner.hash = hash(&args);
miner.block_id = block.id;
}
@@ -165,6 +166,7 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
block_id: block.id,
deployed: amount,
total_deployed: block.total_deployed,
remaining_commitment: permit_commitment,
ts: clock.unix_timestamp,
}
.to_bytes(),