diff --git a/api/src/event.rs b/api/src/event.rs index 0fa55bf..8a2ecb2 100644 --- a/api/src/event.rs +++ b/api/src/event.rs @@ -7,14 +7,9 @@ pub struct MineEvent { pub reward: u64, pub timing: i64, pub balance: u64, -} - -#[repr(C)] -#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)] -pub struct BoostEvent { - pub mint: Pubkey, - pub reward: u64, + pub boost_1: u64, + pub boost_2: u64, + pub boost_3: u64, } event!(MineEvent); -event!(BoostEvent); diff --git a/program/src/mine.rs b/program/src/mine.rs index dabaf58..529497c 100644 --- a/program/src/mine.rs +++ b/program/src/mine.rs @@ -122,7 +122,7 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { // Boosts are staking incentives that can multiply a miner's rewards. Up to 3 boosts can be applied // on any given mine operation. let base_reward = reward; - let mut boost_events: Vec = vec![]; + let mut boost_rewards = [0u64; 3]; let mut applied_boosts = [Pubkey::new_from_array([0; 32]); 3]; for i in 0..3 { if optional_accounts.len().gt(&(i * 2)) { @@ -156,10 +156,7 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { reward = reward.checked_add(boost_reward).unwrap(); // Push boost event - boost_events.push(BoostEvent { - mint: boost.mint, - reward: boost_reward, - }); + boost_rewards[i] = boost_reward; } } } @@ -224,18 +221,16 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { proof.total_hashes = proof.total_hashes.saturating_add(1); proof.total_rewards = proof.total_rewards.saturating_add(reward_actual); - // Log events. + // Log data. // // The boost rewards are scaled down before logging to account for penalties and bus limits. - // These logs can be used by pool operators to calculate miner and staker rewards. - sol_log(format!("Base: {}", reward_actual).as_str()); - for mut e in boost_events.into_iter() { - e.reward = (e.reward as u128) + // This return data can be used by pool operators to calculate miner and staker rewards. + for i in 0..3 { + boost_rewards[i] = (boost_rewards[i] as u128) .checked_mul(reward_actual as u128) .unwrap() .checked_div(reward_pre_penalty as u128) .unwrap() as u64; - sol_log_data(&[e.to_bytes()]); } set_return_data( MineEvent { @@ -243,6 +238,9 @@ pub fn process_mine(accounts: &[AccountInfo], data: &[u8]) -> ProgramResult { reward: reward_actual, timing: t.saturating_sub(t_liveness), balance: proof.balance, + boost_1: boost_rewards[0], + boost_2: boost_rewards[1], + boost_3: boost_rewards[2], } .to_bytes(), );