Skip to content

Commit 0cccdfa

Browse files
committed
small tweak
1 parent 80c7fa2 commit 0cccdfa

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/dynamic_fee.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ impl Miner {
8787
.unwrap(),
8888
FeeStrategy::Triton => {
8989
serde_json::from_value::<Vec<RpcPrioritizationFee>>(response["result"].clone())
90-
.map(|arr| estimate_prioritization_fee_micro_lamports(&arr))
91-
.or_else(|error| {
90+
.map(|prioritization_fees| {
91+
estimate_prioritization_fee_micro_lamports(prioritization_fees)
92+
})
93+
.or_else(|error: serde_json::Error| {
9294
Err(format!(
9395
"Failed to parse priority fee. Response: {response:?}, error: {error}"
9496
))
@@ -107,18 +109,17 @@ impl Miner {
107109
}
108110

109111
/// Our estimate is the average over the last 20 slots
110-
/// Take last 20 slots and average
111112
pub fn estimate_prioritization_fee_micro_lamports(
112-
prioritization_fees: &[RpcPrioritizationFee],
113+
prioritization_fees: Vec<RpcPrioritizationFee>,
113114
) -> u64 {
114115
let prioritization_fees = prioritization_fees
115-
.iter()
116+
.into_iter()
116117
.rev()
117118
.take(20)
118119
.map(
119120
|RpcPrioritizationFee {
120121
prioritization_fee, ..
121-
}| *prioritization_fee,
122+
}| prioritization_fee,
122123
)
123124
.collect::<Vec<_>>();
124125
if prioritization_fees.is_empty() {

0 commit comments

Comments
 (0)