feat: get epoch schedule rpc, update cli (#6500)

This commit is contained in:
Sunny Gleason
2019-10-22 16:41:18 -04:00
committed by GitHub
parent 4f25013954
commit 0b2d4f32fa
4 changed files with 66 additions and 20 deletions

View File

@@ -9,6 +9,7 @@ use serde_json::{json, Value};
use solana_sdk::{
account::Account,
clock::{Slot, DEFAULT_TICKS_PER_SECOND, DEFAULT_TICKS_PER_SLOT},
epoch_schedule::EpochSchedule,
fee_calculator::FeeCalculator,
hash::Hash,
inflation::Inflation,
@@ -138,6 +139,25 @@ impl RpcClient {
})
}
pub fn get_epoch_schedule(&self) -> io::Result<EpochSchedule> {
let response = self
.client
.send(&RpcRequest::GetEpochSchedule, None, 0)
.map_err(|err| {
io::Error::new(
io::ErrorKind::Other,
format!("GetEpochSchedule request failure: {:?}", err),
)
})?;
serde_json::from_value(response).map_err(|err| {
io::Error::new(
io::ErrorKind::Other,
format!("GetEpochSchedule parse failure: {}", err),
)
})
}
pub fn get_inflation(&self) -> io::Result<Inflation> {
let response = self
.client

View File

@@ -58,6 +58,7 @@ pub enum RpcRequest {
GetBalance,
GetClusterNodes,
GetEpochInfo,
GetEpochSchedule,
GetGenesisBlockhash,
GetInflation,
GetNumBlocksSinceSignatureConfirmation,
@@ -91,6 +92,7 @@ impl RpcRequest {
RpcRequest::GetBalance => "getBalance",
RpcRequest::GetClusterNodes => "getClusterNodes",
RpcRequest::GetEpochInfo => "getEpochInfo",
RpcRequest::GetEpochSchedule => "getEpochSchedule",
RpcRequest::GetGenesisBlockhash => "getGenesisBlockhash",
RpcRequest::GetInflation => "getInflation",
RpcRequest::GetNumBlocksSinceSignatureConfirmation => {