From dae14334d3a889ca6eff6719956120d409303545 Mon Sep 17 00:00:00 2001 From: Hardhat Chad Date: Tue, 24 Sep 2024 05:55:15 +0000 Subject: [PATCH] skip duplicate boost --- api/src/error.rs | 2 -- program/src/mine.rs | 7 +++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/api/src/error.rs b/api/src/error.rs index 2e3d81e..b0653ba 100644 --- a/api/src/error.rs +++ b/api/src/error.rs @@ -21,8 +21,6 @@ pub enum OreError { MaxSupply = 6, #[error("The proof does not match the expected account")] AuthFailed = 7, - #[error("The same boost cannot be applied twice")] - DuplicateBoost = 8, } error!(OreError); diff --git a/program/src/mine.rs b/program/src/mine.rs index d0fc76a..488a09b 100644 --- a/program/src/mine.rs +++ b/program/src/mine.rs @@ -148,9 +148,9 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult load_any_boost(&boost_info, false)?; load_stake(&stake_info, &proof.authority, boost_info.key, false)?; - // Reject if boost is applied twice. + // Skip if boost is applied twice. if boosts.contains(boost_info.key) { - return Err(OreError::DuplicateBoost.into()); + continue; } // Record this boost has been used. @@ -162,8 +162,7 @@ pub fn process_mine(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult let stake_data = stake_info.data.borrow(); let stake = Stake::try_from_bytes(&stake_data)?; - // Apply multiplier if boost is not expired and - // last stake was greater than one minute ago. + // Apply multiplier if boost is not expired and last stake at was more than one minute ago. if boost.expires_at.gt(&t) && stake.last_stake_at.saturating_add(ONE_MINUTE).le(&t) { let multiplier = boost.multiplier.checked_sub(1).unwrap(); let boost_reward = (reward as u128)