diff --git a/src/claim.rs b/src/claim.rs index 12ca607..e7242ad 100644 --- a/src/claim.rs +++ b/src/claim.rs @@ -72,7 +72,7 @@ impl Miner { // Send and confirm ixs.push(ore_api::instruction::claim(pubkey, beneficiary, amount)); - self.send_and_confirm(&ixs, ComputeBudget::Fixed(CU_LIMIT_CLAIM), false) + self.send_and_confirm(&ixs, ComputeBudget::Fixed(CU_LIMIT_CLAIM), false, None) .await .ok(); } @@ -99,7 +99,7 @@ impl Miner { &ore_api::consts::MINT_ADDRESS, &spl_token::id(), ); - self.send_and_confirm(&[ix], ComputeBudget::Dynamic, false) + self.send_and_confirm(&[ix], ComputeBudget::Dynamic, false, None) .await .ok(); diff --git a/src/close.rs b/src/close.rs index 72695df..9af5f38 100644 --- a/src/close.rs +++ b/src/close.rs @@ -37,7 +37,7 @@ impl Miner { // Submit close transaction let ix = ore_api::instruction::close(signer.pubkey()); - self.send_and_confirm(&[ix], ComputeBudget::Dynamic, false) + self.send_and_confirm(&[ix], ComputeBudget::Dynamic, false, None) .await .ok(); } diff --git a/src/mine.rs b/src/mine.rs index c773f7f..4408b9e 100644 --- a/src/mine.rs +++ b/src/mine.rs @@ -117,7 +117,12 @@ impl Miner { // .await // .ok(); if self - .send_and_confirm(&ixs, ComputeBudget::Fixed(compute_budget), false) + .send_and_confirm( + &ixs, + ComputeBudget::Fixed(compute_budget), + false, + Some(solution.to_hash().difficulty()), + ) .await .is_ok() { @@ -180,9 +185,24 @@ impl Miner { if nonce % 100 == 0 { if timer.elapsed().as_secs().ge(&cutoff_time) { if best_difficulty.ge(&min_difficulty) { - // Mine until min difficulty has been met - break; - } + if best_difficulty >= 18 { + // Mine until min difficulty has been met + break; + } else { + // delay extra 30 secs + progress_bar.set_message(format!( + "Mining... ({} sec surpassed)", + timer.elapsed().as_secs().saturating_sub(cutoff_time), + )); + if timer + .elapsed() + .as_secs() + .ge(&cutoff_time.saturating_add(29)) + { + break; + } + } + } } else if i.id == 0 { progress_bar.set_message(format!( "Mining... ({} sec remaining)", @@ -267,8 +287,23 @@ impl Miner { if nonce % 100 == 0 { if timer.elapsed().as_secs().ge(&cutoff_time) { if best_difficulty.ge(&min_difficulty) { - // Mine until min difficulty has been met - break; + if best_difficulty >= 18 { + // Mine until min difficulty has been met + break; + } else { + // delay extra 30 secs + progress_bar.set_message(format!( + "Mining... ({} sec surpassed)", + timer.elapsed().as_secs().saturating_sub(cutoff_time), + )); + if timer + .elapsed() + .as_secs() + .ge(&cutoff_time.saturating_add(29)) + { + break; + } + } } } else if i == 0 { progress_bar.set_message(format!( diff --git a/src/open.rs b/src/open.rs index 640b9c9..8761975 100644 --- a/src/open.rs +++ b/src/open.rs @@ -15,7 +15,7 @@ impl Miner { // Sign and send transaction. println!("Generating challenge..."); let ix = ore_api::instruction::open(signer.pubkey(), signer.pubkey(), fee_payer.pubkey()); - self.send_and_confirm(&[ix], ComputeBudget::Dynamic, false) + self.send_and_confirm(&[ix], ComputeBudget::Dynamic, false, None) .await .ok(); } diff --git a/src/send_and_confirm.rs b/src/send_and_confirm.rs index 44ef30c..88c33e4 100644 --- a/src/send_and_confirm.rs +++ b/src/send_and_confirm.rs @@ -41,6 +41,7 @@ impl Miner { ixs: &[Instruction], compute_budget: ComputeBudget, skip_confirm: bool, + difficulty: Option, // MI ) -> ClientResult { let signer = self.signer(); let client = self.rpc_client.clone(); @@ -90,8 +91,19 @@ impl Miner { // Reset the compute unit price if self.dynamic_fee { let fee = if let Some(fee) = self.dynamic_fee().await { - progress_bar.println(format!(" Priority fee: {} microlamports", fee)); - fee + let mut prio_fee = fee; + // MI: upbound 300K for diff > 21 + if let Some(difficulty) = difficulty { + if difficulty > 21 { + prio_fee = + 300_000.min(prio_fee.saturating_mul(15).saturating_div(10)); + } else if difficulty < 18 { + // prio_fee = 5000.max(prio_fee.saturating_mul(2).saturating_div(3)); + // keep priority fee recommendation + } + } + progress_bar.println(format!(" Priority fee: {} microlamports", prio_fee)); + prio_fee } else { let fee = self.priority_fee.unwrap_or(0); progress_bar.println(format!(" {} Dynamic fees not supported by this RPC. Falling back to static value: {} microlamports", "WARNING".bold().yellow(), fee)); diff --git a/src/stake.rs b/src/stake.rs index a820040..322cb81 100644 --- a/src/stake.rs +++ b/src/stake.rs @@ -36,7 +36,7 @@ impl Miner { // Send tx let ix = ore_api::instruction::stake(signer.pubkey(), sender, amount); - self.send_and_confirm(&[ix], ComputeBudget::Fixed(CU_LIMIT_CLAIM), false) + self.send_and_confirm(&[ix], ComputeBudget::Fixed(CU_LIMIT_CLAIM), false, None) .await .ok(); } diff --git a/src/upgrade.rs b/src/upgrade.rs index ca4fef1..f40c0a8 100644 --- a/src/upgrade.rs +++ b/src/upgrade.rs @@ -40,7 +40,7 @@ impl Miner { let ix = ore_api::instruction::upgrade(signer.pubkey(), beneficiary, sender, amount); match self - .send_and_confirm(&[ix], ComputeBudget::Fixed(CU_LIMIT_UPGRADE), false) + .send_and_confirm(&[ix], ComputeBudget::Fixed(CU_LIMIT_UPGRADE), false, None) .await { Ok(_sig) => {} @@ -105,7 +105,7 @@ impl Miner { &ore_api::consts::MINT_ADDRESS, &spl_token::id(), ); - self.send_and_confirm(&[ix], ComputeBudget::Dynamic, false) + self.send_and_confirm(&[ix], ComputeBudget::Dynamic, false, None) .await .ok(); }