debug logs

This commit is contained in:
Hardhat Chad
2025-08-18 09:14:15 -07:00
parent 8c440a117a
commit 22f7e68b40
2 changed files with 14 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
use std::collections::HashMap;
use ore_api::prelude::*;
use solana_program::slot_hashes::SlotHashes;
use solana_program::{log::sol_log, slot_hashes::SlotHashes};
use steel::*;
/// Resets a block.
@@ -53,6 +53,10 @@ pub fn process_reset(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResul
let max_reward = MAX_SUPPLY.saturating_sub(ore_mint.supply());
let block_reward = block_reward.min(max_reward);
sol_log(&format!("slot_hash: {:?}", block_prev.slot_hash));
sol_log(&format!("max_reward: {}", max_reward));
sol_log(&format!("block_reward: {}", block_reward));
// Set the block reward.
block_prev.reward = block_reward;
@@ -183,6 +187,11 @@ fn calculate_block_reward(slot_hash: &[u8]) -> u64 {
let r3 = u64::from_le_bytes(slot_hash[16..24].try_into().unwrap());
let r4 = u64::from_le_bytes(slot_hash[24..32].try_into().unwrap());
let r = r1 ^ r2 ^ r3 ^ r4;
sol_log(&format!("r1: {}", r1));
sol_log(&format!("r2: {}", r2));
sol_log(&format!("r3: {}", r3));
sol_log(&format!("r4: {}", r4));
sol_log(&format!("r: {}", r));
for (k, v) in block_distribution.iter() {
if r <= *v {
return *k * ONE_ORE;

View File

@@ -112,6 +112,8 @@ pub fn process_swap(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
miner.total_hashpower += swap_event.base_to_transfer;
block.total_hashpower += swap_event.base_to_transfer;
// TODO if base to transfer is 0, then fail
// Transfer ORE from signer to market.
transfer(
signer_info,
@@ -127,6 +129,8 @@ pub fn process_swap(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult
miner.total_hashpower -= swap_event.base_to_transfer;
block.total_hashpower -= swap_event.base_to_transfer;
// TODO if quote to transfer is 0, then fail
// Transfer ORE from market to signer.
transfer_signed(
market_info,