Skip to content

Commit 6c5ae4b

Browse files
authored
Update send_and_confirm.rs
1 parent 6037192 commit 6c5ae4b

File tree

1 file changed

+11
-23
lines changed

1 file changed

+11
-23
lines changed

src/send_and_confirm.rs

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,7 @@ impl Miner {
6363

6464
// Set compute unit price
6565
final_ixs.push(ComputeBudgetInstruction::set_compute_unit_price(
66-
if self.dynamic_fee {
67-
if let Some(dynamic_fee) = self.dynamic_fee().await {
68-
dynamic_fee
69-
}else{
70-
self.priority_fee.unwrap_or(0)
71-
}
72-
} else {
73-
self.priority_fee.unwrap_or(0)
74-
}
66+
self.priority_fee.unwrap_or(0),
7567
));
7668

7769
// Add in user instructions
@@ -97,21 +89,17 @@ impl Miner {
9789
if attempts % 10 == 0 {
9890
// Reset the compute unit price
9991
if self.dynamic_fee {
100-
if let Some(dynamic_fee) = self.dynamic_fee().await {
101-
progress_bar.println(format!(" Priority fee: {} microlamports", dynamic_fee));
102-
final_ixs.remove(1);
103-
final_ixs.insert(1, ComputeBudgetInstruction::set_compute_unit_price(dynamic_fee));
92+
let fee = if let Some(fee) = self.dynamic_fee().await {
93+
progress_bar.println(format!(" Priority fee: {} microlamports", fee));
94+
fee
10495
} else {
105-
let fallback_fee = self.priority_fee.unwrap_or(0);
106-
progress_bar.println(format!(
107-
"{} Dynamic fees not supported by this RPC. Falling back to static value: {} microlamports",
108-
"WARNING".bold().yellow(),
109-
fallback_fee
110-
));
111-
final_ixs.remove(1);
112-
final_ixs.insert(1, ComputeBudgetInstruction::set_compute_unit_price(fallback_fee));
113-
}
114-
}
96+
let fee = self.priority_fee.unwrap_or(0);
97+
progress_bar.println(format!(" {} Dynamic fees not supported by this RPC. Falling back to static value: {} microlamports", "WARNING".bold().yellow(), fee));
98+
fee
99+
};
100+
final_ixs.remove(1);
101+
final_ixs.insert(1, ComputeBudgetInstruction::set_compute_unit_price(fee));
102+
}
115103

116104
// Resign the tx
117105
let (hash, _slot) = client

0 commit comments

Comments
 (0)