mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 15:10:13 +00:00
noise seed
This commit is contained in:
@@ -81,6 +81,7 @@ pub fn process_commit(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResul
|
||||
// Update executor logic.
|
||||
permit.executor = executor;
|
||||
permit.fee = fee;
|
||||
permit.seed = args.seed;
|
||||
|
||||
// Transfer hash tokens.
|
||||
transfer(
|
||||
|
||||
@@ -87,12 +87,13 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
|
||||
// Reset miner hash if mining new block.
|
||||
if miner.block_id != block.id {
|
||||
miner.block_id = block.id;
|
||||
let mut args = [0u8; 96];
|
||||
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..].copy_from_slice(&miner.authority.to_bytes());
|
||||
args[64..96].copy_from_slice(&permit.authority.to_bytes());
|
||||
args[96..].copy_from_slice(&permit.seed);
|
||||
miner.hash = hash(&args);
|
||||
miner.block_id = block.id;
|
||||
}
|
||||
|
||||
// Mine and accumulate rewards.
|
||||
@@ -108,8 +109,6 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
// Score and increment rewards.
|
||||
let score = difficulty(miner.hash) as u64;
|
||||
if score >= block.reward.nugget_threshold {
|
||||
block.winning_hashes += 1;
|
||||
miner.winning_hashes += 1;
|
||||
miner_reward += block.reward.nugget_reward;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,6 @@ pub fn process_open(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
|
||||
block.slot_hash = [0; 32];
|
||||
block.start_slot = start_slot;
|
||||
block.total_hashes = 0;
|
||||
block.winning_hashes = 0;
|
||||
|
||||
// Select reward strategy.
|
||||
let noise_seed = block.id.to_le_bytes();
|
||||
|
||||
Reference in New Issue
Block a user