Add ping cli option to use CommitmentLevel::Max, instead of CommitmentLevel::Recent (#6775)
This commit is contained in:
committed by
Michael Vines
parent
2491719f36
commit
079682fbdc
@ -15,6 +15,7 @@ use solana_drone::drone::request_airdrop_transaction;
|
|||||||
use solana_drone::drone_mock::request_airdrop_transaction;
|
use solana_drone::drone_mock::request_airdrop_transaction;
|
||||||
use solana_sdk::{
|
use solana_sdk::{
|
||||||
bpf_loader,
|
bpf_loader,
|
||||||
|
commitment_config::CommitmentConfig,
|
||||||
fee_calculator::FeeCalculator,
|
fee_calculator::FeeCalculator,
|
||||||
hash::Hash,
|
hash::Hash,
|
||||||
instruction::InstructionError,
|
instruction::InstructionError,
|
||||||
@ -56,6 +57,7 @@ pub enum CliCommand {
|
|||||||
interval: Duration,
|
interval: Duration,
|
||||||
count: Option<u64>,
|
count: Option<u64>,
|
||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
|
commitment_config: CommitmentConfig,
|
||||||
},
|
},
|
||||||
ShowValidators {
|
ShowValidators {
|
||||||
use_lamports_unit: bool,
|
use_lamports_unit: bool,
|
||||||
@ -824,7 +826,15 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
interval,
|
interval,
|
||||||
count,
|
count,
|
||||||
timeout,
|
timeout,
|
||||||
} => process_ping(&rpc_client, config, interval, count, timeout),
|
commitment_config,
|
||||||
|
} => process_ping(
|
||||||
|
&rpc_client,
|
||||||
|
config,
|
||||||
|
interval,
|
||||||
|
count,
|
||||||
|
timeout,
|
||||||
|
commitment_config,
|
||||||
|
),
|
||||||
CliCommand::ShowValidators { use_lamports_unit } => {
|
CliCommand::ShowValidators { use_lamports_unit } => {
|
||||||
process_show_validators(&rpc_client, *use_lamports_unit)
|
process_show_validators(&rpc_client, *use_lamports_unit)
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,14 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.default_value("15")
|
.default_value("15")
|
||||||
.help("Wait up to timeout seconds for transaction confirmation"),
|
.help("Wait up to timeout seconds for transaction confirmation"),
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("confirmed")
|
||||||
|
.long("confirmed")
|
||||||
|
.takes_value(false)
|
||||||
|
.help(
|
||||||
|
"Wait until the transaction is confirmed at maximum-lockout commitment level",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
@ -98,11 +106,17 @@ pub fn parse_cluster_ping(matches: &ArgMatches<'_>) -> Result<CliCommandInfo, Cl
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64));
|
let timeout = Duration::from_secs(value_t_or_exit!(matches, "timeout", u64));
|
||||||
|
let commitment_config = if matches.is_present("confirmed") {
|
||||||
|
CommitmentConfig::default()
|
||||||
|
} else {
|
||||||
|
CommitmentConfig::recent()
|
||||||
|
};
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::Ping {
|
command: CliCommand::Ping {
|
||||||
interval,
|
interval,
|
||||||
count,
|
count,
|
||||||
timeout,
|
timeout,
|
||||||
|
commitment_config,
|
||||||
},
|
},
|
||||||
require_keypair: true,
|
require_keypair: true,
|
||||||
})
|
})
|
||||||
@ -193,6 +207,7 @@ pub fn process_ping(
|
|||||||
interval: &Duration,
|
interval: &Duration,
|
||||||
count: &Option<u64>,
|
count: &Option<u64>,
|
||||||
timeout: &Duration,
|
timeout: &Duration,
|
||||||
|
commitment_config: &CommitmentConfig,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
let to = Keypair::new().pubkey();
|
let to = Keypair::new().pubkey();
|
||||||
|
|
||||||
@ -224,7 +239,7 @@ pub fn process_ping(
|
|||||||
loop {
|
loop {
|
||||||
let signature_status = rpc_client.get_signature_status_with_commitment(
|
let signature_status = rpc_client.get_signature_status_with_commitment(
|
||||||
&signature,
|
&signature,
|
||||||
CommitmentConfig::recent(),
|
commitment_config.clone(),
|
||||||
)?;
|
)?;
|
||||||
let elapsed_time = Instant::now().duration_since(transaction_sent);
|
let elapsed_time = Instant::now().duration_since(transaction_sent);
|
||||||
if let Some(transaction_status) = signature_status {
|
if let Some(transaction_status) = signature_status {
|
||||||
@ -481,9 +496,17 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let test_ping = test_commands
|
let test_ping = test_commands.clone().get_matches_from(vec![
|
||||||
.clone()
|
"test",
|
||||||
.get_matches_from(vec!["test", "ping", "-i", "1", "-c", "2", "-t", "3"]);
|
"ping",
|
||||||
|
"-i",
|
||||||
|
"1",
|
||||||
|
"-c",
|
||||||
|
"2",
|
||||||
|
"-t",
|
||||||
|
"3",
|
||||||
|
"--confirmed",
|
||||||
|
]);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_command(&test_ping).unwrap(),
|
parse_command(&test_ping).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
@ -491,6 +514,7 @@ mod tests {
|
|||||||
interval: Duration::from_secs(1),
|
interval: Duration::from_secs(1),
|
||||||
count: Some(2),
|
count: Some(2),
|
||||||
timeout: Duration::from_secs(3),
|
timeout: Duration::from_secs(3),
|
||||||
|
commitment_config: CommitmentConfig::default(),
|
||||||
},
|
},
|
||||||
require_keypair: true
|
require_keypair: true
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user