@ -188,6 +188,9 @@ pub enum CliCommand {
|
|||||||
commitment_config: CommitmentConfig,
|
commitment_config: CommitmentConfig,
|
||||||
},
|
},
|
||||||
GetGenesisHash,
|
GetGenesisHash,
|
||||||
|
GetEpoch {
|
||||||
|
commitment_config: CommitmentConfig,
|
||||||
|
},
|
||||||
GetSlot {
|
GetSlot {
|
||||||
commitment_config: CommitmentConfig,
|
commitment_config: CommitmentConfig,
|
||||||
},
|
},
|
||||||
@ -583,6 +586,7 @@ pub fn parse_command(
|
|||||||
command: CliCommand::GetGenesisHash,
|
command: CliCommand::GetGenesisHash,
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
}),
|
}),
|
||||||
|
("epoch", Some(matches)) => parse_get_epoch(matches),
|
||||||
("slot", Some(matches)) => parse_get_slot(matches),
|
("slot", Some(matches)) => parse_get_slot(matches),
|
||||||
("transaction-count", Some(matches)) => parse_get_transaction_count(matches),
|
("transaction-count", Some(matches)) => parse_get_transaction_count(matches),
|
||||||
("leader-schedule", Some(_matches)) => Ok(CliCommandInfo {
|
("leader-schedule", Some(_matches)) => Ok(CliCommandInfo {
|
||||||
@ -1598,6 +1602,9 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
CliCommand::GetEpochInfo { commitment_config } => {
|
CliCommand::GetEpochInfo { commitment_config } => {
|
||||||
process_get_epoch_info(&rpc_client, *commitment_config)
|
process_get_epoch_info(&rpc_client, *commitment_config)
|
||||||
}
|
}
|
||||||
|
CliCommand::GetEpoch { commitment_config } => {
|
||||||
|
process_get_epoch(&rpc_client, *commitment_config)
|
||||||
|
}
|
||||||
CliCommand::GetSlot { commitment_config } => {
|
CliCommand::GetSlot { commitment_config } => {
|
||||||
process_get_slot(&rpc_client, *commitment_config)
|
process_get_slot(&rpc_client, *commitment_config)
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,17 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("epoch").about("Get current epoch")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("confirmed")
|
||||||
|
.long("confirmed")
|
||||||
|
.takes_value(false)
|
||||||
|
.help(
|
||||||
|
"Return epoch at maximum-lockout commitment level",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("transaction-count").about("Get current transaction count")
|
SubCommand::with_name("transaction-count").about("Get current transaction count")
|
||||||
.alias("get-transaction-count")
|
.alias("get-transaction-count")
|
||||||
@ -325,6 +336,18 @@ pub fn parse_get_slot(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliErr
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parse_get_epoch(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
|
let commitment_config = if matches.is_present("confirmed") {
|
||||||
|
CommitmentConfig::default()
|
||||||
|
} else {
|
||||||
|
CommitmentConfig::recent()
|
||||||
|
};
|
||||||
|
Ok(CliCommandInfo {
|
||||||
|
command: CliCommand::GetEpoch { commitment_config },
|
||||||
|
signers: vec![],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_get_transaction_count(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_get_transaction_count(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let commitment_config = if matches.is_present("confirmed") {
|
let commitment_config = if matches.is_present("confirmed") {
|
||||||
CommitmentConfig::default()
|
CommitmentConfig::default()
|
||||||
@ -575,6 +598,14 @@ pub fn process_get_slot(
|
|||||||
Ok(slot.to_string())
|
Ok(slot.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn process_get_epoch(
|
||||||
|
rpc_client: &RpcClient,
|
||||||
|
commitment_config: CommitmentConfig,
|
||||||
|
) -> ProcessResult {
|
||||||
|
let epoch_info = rpc_client.get_epoch_info_with_commitment(commitment_config.clone())?;
|
||||||
|
Ok(epoch_info.epoch.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn parse_show_block_production(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
pub fn parse_show_block_production(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, CliError> {
|
||||||
let epoch = value_t!(matches, "epoch", Epoch).ok();
|
let epoch = value_t!(matches, "epoch", Epoch).ok();
|
||||||
let slot_limit = value_t!(matches, "slot_limit", u64).ok();
|
let slot_limit = value_t!(matches, "slot_limit", u64).ok();
|
||||||
@ -1280,6 +1311,19 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let test_get_epoch = test_commands
|
||||||
|
.clone()
|
||||||
|
.get_matches_from(vec!["test", "epoch"]);
|
||||||
|
assert_eq!(
|
||||||
|
parse_command(&test_get_epoch, &default_keypair_file, None).unwrap(),
|
||||||
|
CliCommandInfo {
|
||||||
|
command: CliCommand::GetEpoch {
|
||||||
|
commitment_config: CommitmentConfig::recent(),
|
||||||
|
},
|
||||||
|
signers: vec![],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
let test_transaction_count = test_commands
|
let test_transaction_count = test_commands
|
||||||
.clone()
|
.clone()
|
||||||
.get_matches_from(vec!["test", "transaction-count"]);
|
.get_matches_from(vec!["test", "transaction-count"]);
|
||||||
|
Reference in New Issue
Block a user