Skip to content

Commit fe95448

Browse files
authored
add lut metrics (#4)
1 parent 5a502b8 commit fe95448

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/rpc_server.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ use std::{
33
env, fmt,
44
str::FromStr,
55
sync::Arc,
6+
time::Instant,
67
};
78

89
use crate::{
910
errors::invalid_request,
1011
priority_fee::{MicroLamportPriorityFeeEstimates, PriorityFeeTracker, PriorityLevel},
1112
solana::solana_rpc::decode_and_deserialize,
1213
};
14+
use cadence_macros::{statsd_count, statsd_time};
1315
use jsonrpsee::{
1416
core::{async_trait, RpcResult},
1517
proc_macros::rpc,
@@ -131,6 +133,7 @@ fn get_from_address_lookup_tables(
131133
let address_table_lookups: Option<&[solana_sdk::message::v0::MessageAddressTableLookup]> =
132134
transaction.message.address_table_lookups();
133135
if let Some(address_table_lookups) = address_table_lookups {
136+
let start = Instant::now();
134137
let mut lookup_table_indices = HashMap::new();
135138
let address_table_lookup_accounts: Vec<Pubkey> = address_table_lookups
136139
.iter()
@@ -142,6 +145,10 @@ fn get_from_address_lookup_tables(
142145
a.account_key
143146
})
144147
.collect();
148+
statsd_count!(
149+
"get_from_address_lookup_tables_num_accounts",
150+
address_table_lookup_accounts.len() as i64
151+
);
145152
let accounts = rpc_client.get_multiple_accounts(address_table_lookup_accounts.as_slice());
146153
match accounts {
147154
Ok(accounts) => {
@@ -185,6 +192,7 @@ fn get_from_address_lookup_tables(
185192
info!("error getting accounts: {:?}", e);
186193
}
187194
}
195+
statsd_time!("get_from_address_lookup_tables", start.elapsed());
188196
}
189197
account_keys
190198
}
@@ -279,7 +287,9 @@ impl AtlasPriorityFeeEstimatorRpcServer for AtlasPriorityFeeEstimator {
279287
});
280288
}
281289
}
282-
let recommended = options.map_or(false, |o: GetPriorityFeeEstimateOptions| o.recommended.unwrap_or(false));
290+
let recommended = options.map_or(false, |o: GetPriorityFeeEstimateOptions| {
291+
o.recommended.unwrap_or(false)
292+
});
283293
let priority_fee = if recommended {
284294
get_recommended_fee(priority_fee_levels)
285295
} else {
@@ -317,7 +327,7 @@ fn should_include_vote(options: &Option<GetPriorityFeeEstimateOptions>) -> bool
317327

318328
const MIN_RECOMMENDED_PRIORITY_FEE: f64 = 10_000.0;
319329

320-
// Safety buffer on the recommended fee to cover cases where the priority fee is increasing over each block.
330+
// Safety buffer on the recommended fee to cover cases where the priority fee is increasing over each block.
321331
const RECOMMENDED_FEE_SAFETY_BUFFER: f64 = 0.05;
322332

323333
pub fn get_recommended_fee(priority_fee_levels: MicroLamportPriorityFeeEstimates) -> f64 {

0 commit comments

Comments
 (0)