Add block-height subcommand

This commit is contained in:
Michael Vines
2020-07-22 08:36:12 -07:00
parent 2adfe3f199
commit 50c92e3a94
3 changed files with 26 additions and 1 deletions

View File

@@ -115,6 +115,10 @@ impl ClusterQuerySubCommands for App<'_, '_> {
.alias("get-slot")
.arg(commitment_arg()),
)
.subcommand(
SubCommand::with_name("block-height").about("Get current block height")
.arg(commitment_arg()),
)
.subcommand(
SubCommand::with_name("epoch").about("Get current epoch")
.arg(commitment_arg()),
@@ -362,6 +366,13 @@ pub fn parse_get_slot(_matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliEr
})
}
pub fn parse_get_block_height(_matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
Ok(CliCommandInfo {
command: CliCommand::GetBlockHeight,
signers: vec![],
})
}
pub fn parse_largest_accounts(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
let filter = if matches.is_present("circulating") {
Some(RpcLargestAccountsFilter::Circulating)
@@ -651,6 +662,13 @@ pub fn process_get_slot(rpc_client: &RpcClient, config: &CliConfig) -> ProcessRe
Ok(slot.to_string())
}
pub fn process_get_block_height(rpc_client: &RpcClient, config: &CliConfig) -> ProcessResult {
let epoch_info: CliEpochInfo = rpc_client
.get_epoch_info_with_commitment(config.commitment)?
.into();
Ok(epoch_info.epoch_info.block_height.to_string())
}
pub fn parse_show_block_production(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
let epoch = value_t!(matches, "epoch", Epoch).ok();
let slot_limit = value_t!(matches, "slot_limit", u64).ok();