introduce RpcPerfSample and modify getPerformanceSamples output (#12434)
* introduce RpcPerfSample and modify getPerformanceSamples output * camelCase test results
This commit is contained in:
parent
c4aee8c0a0
commit
1d04c1db94
|
@ -275,6 +275,15 @@ pub struct RpcConfirmedTransactionStatusWithSignature {
|
||||||
pub memo: Option<String>,
|
pub memo: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct RpcPerfSample {
|
||||||
|
pub slot: Slot,
|
||||||
|
pub num_transactions: u64,
|
||||||
|
pub num_slots: u64,
|
||||||
|
pub sample_period_secs: u16,
|
||||||
|
}
|
||||||
|
|
||||||
impl From<ConfirmedTransactionStatusWithSignature> for RpcConfirmedTransactionStatusWithSignature {
|
impl From<ConfirmedTransactionStatusWithSignature> for RpcConfirmedTransactionStatusWithSignature {
|
||||||
fn from(value: ConfirmedTransactionStatusWithSignature) -> Self {
|
fn from(value: ConfirmedTransactionStatusWithSignature) -> Self {
|
||||||
let ConfirmedTransactionStatusWithSignature {
|
let ConfirmedTransactionStatusWithSignature {
|
||||||
|
|
|
@ -33,10 +33,7 @@ use solana_client::{
|
||||||
rpc_response::*,
|
rpc_response::*,
|
||||||
};
|
};
|
||||||
use solana_faucet::faucet::request_airdrop_transaction;
|
use solana_faucet::faucet::request_airdrop_transaction;
|
||||||
use solana_ledger::{
|
use solana_ledger::{blockstore::Blockstore, blockstore_db::BlockstoreError, get_tmp_ledger_path};
|
||||||
blockstore::Blockstore, blockstore_db::BlockstoreError, blockstore_meta::PerfSample,
|
|
||||||
get_tmp_ledger_path,
|
|
||||||
};
|
|
||||||
use solana_perf::packet::PACKET_DATA_SIZE;
|
use solana_perf::packet::PACKET_DATA_SIZE;
|
||||||
use solana_runtime::{
|
use solana_runtime::{
|
||||||
accounts::AccountAddressFilter,
|
accounts::AccountAddressFilter,
|
||||||
|
@ -1506,7 +1503,7 @@ pub trait RpcSol {
|
||||||
&self,
|
&self,
|
||||||
meta: Self::Metadata,
|
meta: Self::Metadata,
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
) -> Result<Vec<(Slot, PerfSample)>>;
|
) -> Result<Vec<RpcPerfSample>>;
|
||||||
|
|
||||||
#[rpc(meta, name = "getEpochInfo")]
|
#[rpc(meta, name = "getEpochInfo")]
|
||||||
fn get_epoch_info(
|
fn get_epoch_info(
|
||||||
|
@ -1901,7 +1898,7 @@ impl RpcSol for RpcSolImpl {
|
||||||
&self,
|
&self,
|
||||||
meta: Self::Metadata,
|
meta: Self::Metadata,
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
) -> Result<Vec<(Slot, PerfSample)>> {
|
) -> Result<Vec<RpcPerfSample>> {
|
||||||
debug!("get_recent_performance_samples request received");
|
debug!("get_recent_performance_samples request received");
|
||||||
|
|
||||||
let limit = limit.unwrap_or(PERFORMANCE_SAMPLES_LIMIT);
|
let limit = limit.unwrap_or(PERFORMANCE_SAMPLES_LIMIT);
|
||||||
|
@ -1913,12 +1910,21 @@ impl RpcSol for RpcSolImpl {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.blockstore
|
Ok(meta
|
||||||
|
.blockstore
|
||||||
.get_recent_perf_samples(limit)
|
.get_recent_perf_samples(limit)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("get_recent_performance_samples failed: {:?}", err);
|
warn!("get_recent_performance_samples failed: {:?}", err);
|
||||||
Error::invalid_request()
|
Error::invalid_request()
|
||||||
|
})?
|
||||||
|
.iter()
|
||||||
|
.map(|(slot, sample)| RpcPerfSample {
|
||||||
|
slot: *slot,
|
||||||
|
num_transactions: sample.num_transactions,
|
||||||
|
num_slots: sample.num_slots,
|
||||||
|
sample_period_secs: sample.sample_period_secs,
|
||||||
})
|
})
|
||||||
|
.collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_cluster_nodes(&self, meta: Self::Metadata) -> Result<Vec<RpcContactInfo>> {
|
fn get_cluster_nodes(&self, meta: Self::Metadata) -> Result<Vec<RpcContactInfo>> {
|
||||||
|
@ -2547,6 +2553,7 @@ pub mod tests {
|
||||||
use solana_client::rpc_filter::{Memcmp, MemcmpEncodedBytes};
|
use solana_client::rpc_filter::{Memcmp, MemcmpEncodedBytes};
|
||||||
use solana_ledger::{
|
use solana_ledger::{
|
||||||
blockstore::entries_to_test_shreds,
|
blockstore::entries_to_test_shreds,
|
||||||
|
blockstore_meta::PerfSample,
|
||||||
blockstore_processor::fill_blockstore_slot_with_ticks,
|
blockstore_processor::fill_blockstore_slot_with_ticks,
|
||||||
entry::next_entry_mut,
|
entry::next_entry_mut,
|
||||||
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
genesis_utils::{create_genesis_config, GenesisConfigInfo},
|
||||||
|
@ -2861,14 +2868,12 @@ pub mod tests {
|
||||||
"jsonrpc": "2.0",
|
"jsonrpc": "2.0",
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"result": [
|
"result": [
|
||||||
[
|
{
|
||||||
0,
|
"slot": 0,
|
||||||
{
|
"numSlots": 1,
|
||||||
"num_slots": 1,
|
"numTransactions": 4,
|
||||||
"num_transactions": 4,
|
"samplePeriodSecs": 60
|
||||||
"sample_period_secs": 60
|
}
|
||||||
}
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue