cargo fmt
This commit is contained in:
parent
a0b0745b81
commit
0a5bae029d
|
@ -4,8 +4,8 @@ use prometheus::{opts, register_int_gauge, IntGauge};
|
|||
use solana_address_lookup_table_program::state::AddressLookupTable;
|
||||
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
|
||||
use solana_sdk::{account::ReadableAccount, commitment_config::CommitmentConfig, pubkey::Pubkey};
|
||||
use tokio::sync::RwLock;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::block_info::TransactionAccount;
|
||||
lazy_static::lazy_static! {
|
||||
|
@ -17,7 +17,7 @@ lazy_static::lazy_static! {
|
|||
pub struct ALTStore {
|
||||
rpc_client: Arc<RpcClient>,
|
||||
pub map: Arc<DashMap<Pubkey, Vec<Pubkey>>>,
|
||||
is_loading : Arc<DashMap<Pubkey, Arc<tokio::sync::RwLock<()>>>>,
|
||||
is_loading: Arc<DashMap<Pubkey, Arc<tokio::sync::RwLock<()>>>>,
|
||||
}
|
||||
|
||||
impl ALTStore {
|
||||
|
@ -46,7 +46,7 @@ impl ALTStore {
|
|||
let lock = Arc::new(RwLock::new(()));
|
||||
// add in loading list
|
||||
batches.iter().for_each(|x| {
|
||||
self.is_loading.insert( x.clone(), lock.clone());
|
||||
self.is_loading.insert(x.clone(), lock.clone());
|
||||
});
|
||||
let _context = lock.write().await;
|
||||
let tasks = batches.chunks(10).map(|batch| {
|
||||
|
@ -163,7 +163,7 @@ impl ALTStore {
|
|||
let x = x.value().clone();
|
||||
log::debug!("waiting for alt {}", alt.to_string());
|
||||
let _ = x.read().await;
|
||||
},
|
||||
}
|
||||
None => {
|
||||
// not loading
|
||||
}
|
||||
|
|
|
@ -13,7 +13,10 @@ use solana_sdk::{
|
|||
signature::Signature,
|
||||
slot_history::Slot,
|
||||
};
|
||||
use std::{collections::{HashMap, HashSet}, sync::Arc};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
#[derive(Serialize, Debug, Clone)]
|
||||
pub struct PrioFeeData {
|
||||
|
@ -22,7 +25,7 @@ pub struct PrioFeeData {
|
|||
pub p75: Option<u64>,
|
||||
pub p90: Option<u64>,
|
||||
pub p95: Option<u64>,
|
||||
pub med: Option<u64>,
|
||||
pub med: Option<u64>,
|
||||
}
|
||||
|
||||
impl PrioFeeData {
|
||||
|
@ -286,18 +289,18 @@ impl BlockInfo {
|
|||
}
|
||||
|
||||
pub fn calculate_supp_info(
|
||||
prio_fees_in_block: &mut Vec<(u64, u64)>
|
||||
prio_fees_in_block: &mut Vec<(u64, u64)>,
|
||||
) -> Option<PrioritizationFeesInfo> {
|
||||
if !prio_fees_in_block.is_empty() {
|
||||
// get stats by transaction
|
||||
prio_fees_in_block.sort_by(|a,b| a.0.cmp(&b.0));
|
||||
prio_fees_in_block.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
let median_index = prio_fees_in_block.len() / 2;
|
||||
let p75_index = prio_fees_in_block.len() * 75 / 100;
|
||||
let p90_index = prio_fees_in_block.len() * 90 / 100;
|
||||
let p_min = prio_fees_in_block[0].0;
|
||||
let p_median = prio_fees_in_block[median_index].0;
|
||||
let p_75 = prio_fees_in_block[p75_index].0;
|
||||
let p_90 = prio_fees_in_block[p90_index].0;
|
||||
let p_90 = prio_fees_in_block[p90_index].0;
|
||||
let p_max = prio_fees_in_block.last().map(|x| x.0).unwrap_or_default();
|
||||
|
||||
let mut med_cu = None;
|
||||
|
@ -305,18 +308,18 @@ impl BlockInfo {
|
|||
let mut p90_cu = None;
|
||||
let mut p95_cu = None;
|
||||
|
||||
// get stats by CU
|
||||
let cu_sum : u64 = prio_fees_in_block.iter().map(|x| x.1).sum();
|
||||
// get stats by CU
|
||||
let cu_sum: u64 = prio_fees_in_block.iter().map(|x| x.1).sum();
|
||||
let mut agg: u64 = 0;
|
||||
for (prio, cu) in prio_fees_in_block {
|
||||
agg = agg + *cu;
|
||||
if med_cu.is_none() && agg > (cu_sum as f64 * 0.5) as u64 {
|
||||
if med_cu.is_none() && agg > (cu_sum as f64 * 0.5) as u64 {
|
||||
med_cu = Some(*prio);
|
||||
} else if p75_cu.is_none() && agg > (cu_sum as f64 * 0.75) as u64 {
|
||||
} else if p75_cu.is_none() && agg > (cu_sum as f64 * 0.75) as u64 {
|
||||
p75_cu = Some(*prio)
|
||||
} else if p90_cu.is_none() && agg > (cu_sum as f64 * 0.9) as u64 {
|
||||
} else if p90_cu.is_none() && agg > (cu_sum as f64 * 0.9) as u64 {
|
||||
p90_cu = Some(*prio);
|
||||
} else if p95_cu.is_none() && agg > (cu_sum as f64 * 0.95) as u64 {
|
||||
} else if p95_cu.is_none() && agg > (cu_sum as f64 * 0.95) as u64 {
|
||||
p95_cu = Some(*prio)
|
||||
}
|
||||
}
|
||||
|
@ -444,7 +447,9 @@ impl BlockInfo {
|
|||
.collect(),
|
||||
});
|
||||
let atl_store = atl_store.clone();
|
||||
atl_store.load_all_alts(lookup_tables.iter().cloned().collect_vec()).await;
|
||||
atl_store
|
||||
.load_all_alts(lookup_tables.iter().cloned().collect_vec())
|
||||
.await;
|
||||
|
||||
let transaction = Self::process_versioned_message(
|
||||
atl_store,
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -4,8 +4,12 @@ use solana_rpc_client::nonblocking::rpc_client::{self, RpcClient};
|
|||
use solana_sdk::pubkey::Pubkey;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
sync::{atomic::{AtomicU64, AtomicBool}, Arc},
|
||||
time::Duration, str::FromStr,
|
||||
str::FromStr,
|
||||
sync::{
|
||||
atomic::{AtomicBool, AtomicU64},
|
||||
Arc,
|
||||
},
|
||||
time::Duration,
|
||||
};
|
||||
use tokio::io::AsyncReadExt;
|
||||
|
||||
|
@ -138,7 +142,7 @@ async fn start_tracking_blocks(
|
|||
slot: Arc<AtomicU64>,
|
||||
alts_list: Vec<Pubkey>,
|
||||
) {
|
||||
let block_counter = Arc::new(AtomicU64::new(0));
|
||||
let block_counter = Arc::new(AtomicU64::new(0));
|
||||
let restart_block_subscription = Arc::new(AtomicBool::new(false));
|
||||
let _block_counter_checker = {
|
||||
let block_counter = block_counter.clone();
|
||||
|
@ -149,7 +153,9 @@ async fn start_tracking_blocks(
|
|||
tokio::time::sleep(Duration::from_secs(20)).await;
|
||||
let new_count = block_counter.load(std::sync::atomic::Ordering::Relaxed);
|
||||
if old_count > 0 && old_count == new_count {
|
||||
log::error!("Did not recieve any block for 20 s, restarting block subscription");
|
||||
log::error!(
|
||||
"Did not recieve any block for 20 s, restarting block subscription"
|
||||
);
|
||||
restart_block_subscription.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
tokio::time::sleep(Duration::from_secs(10)).await;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue