Skip to content

Commit

Permalink
RPC-468 adding response for detailed request
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-helius committed Nov 18, 2024
1 parent 7f3d3e2 commit 1f30181
Show file tree
Hide file tree
Showing 4 changed files with 523 additions and 78 deletions.
40 changes: 38 additions & 2 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use dashmap::DashMap;
use serde::{Deserialize, Serialize};
use solana_sdk::clock::Slot;
use solana_sdk::pubkey::Pubkey;
use std::fmt::{Debug, Display, Formatter};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
pub enum PriorityLevel {
Expand Down Expand Up @@ -44,6 +45,23 @@ impl Into<Percentile> for PriorityLevel {

pub type Percentile = usize;

#[derive(Debug, Clone, PartialOrd, PartialEq, Eq, Ord, Hash)]
pub enum DataType<'a> {
Global,
AllAccounts,
Account(&'a Pubkey),
}

impl Display for DataType<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
DataType::Global => f.write_str("Global"),
DataType::AllAccounts => f.write_str("All Accounts"),
DataType::Account(pubkey) => f.write_str(pubkey.to_string().as_str()),
}
}
}

#[derive(Deserialize, Serialize, Debug, Clone, Default)]
#[serde(rename_all(serialize = "camelCase", deserialize = "camelCase"))]
pub struct MicroLamportPriorityFeeEstimates {
Expand All @@ -55,6 +73,16 @@ pub struct MicroLamportPriorityFeeEstimates {
pub unsafe_max: f64,
}

#[derive(Deserialize, Serialize, Debug, Clone, Default)]
#[serde(rename_all(serialize = "camelCase", deserialize = "camelCase"))]
pub struct MicroLamportPriorityFeeDetails {
pub estimates: MicroLamportPriorityFeeEstimates,
pub mean: f64,
pub stdev: f64,
pub skew: f64,
pub count: usize,
}

#[derive(Debug, Clone)]
pub struct Fees {
pub(crate) non_vote_fees: Vec<f64>,
Expand Down Expand Up @@ -100,9 +128,17 @@ impl SlotPriorityFees {
account_fees.insert(account, fees.clone());
}
if is_vote {
Self { slot, fees, account_fees }
Self {
slot,
fees,
account_fees,
}
} else {
Self { slot, fees, account_fees }
Self {
slot,
fees,
account_fees,
}
}
}
}
Expand Down
Loading

0 comments on commit 1f30181

Please sign in to comment.