Update ping to transfer to self, with rotating amount (#22657)
* Update ping to transfer to self, with rotating amount * Remove balance check
This commit is contained in:
@ -83,7 +83,6 @@ pub enum CliCommand {
|
|||||||
filter: RpcTransactionLogsFilter,
|
filter: RpcTransactionLogsFilter,
|
||||||
},
|
},
|
||||||
Ping {
|
Ping {
|
||||||
lamports: u64,
|
|
||||||
interval: Duration,
|
interval: Duration,
|
||||||
count: Option<u64>,
|
count: Option<u64>,
|
||||||
timeout: Duration,
|
timeout: Duration,
|
||||||
@ -973,7 +972,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
CliCommand::LiveSlots => process_live_slots(config),
|
CliCommand::LiveSlots => process_live_slots(config),
|
||||||
CliCommand::Logs { filter } => process_logs(config, filter),
|
CliCommand::Logs { filter } => process_logs(config, filter),
|
||||||
CliCommand::Ping {
|
CliCommand::Ping {
|
||||||
lamports,
|
|
||||||
interval,
|
interval,
|
||||||
count,
|
count,
|
||||||
timeout,
|
timeout,
|
||||||
@ -982,7 +980,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
} => process_ping(
|
} => process_ping(
|
||||||
&rpc_client,
|
&rpc_client,
|
||||||
config,
|
config,
|
||||||
*lamports,
|
|
||||||
interval,
|
interval,
|
||||||
count,
|
count,
|
||||||
timeout,
|
timeout,
|
||||||
|
@ -44,13 +44,13 @@ use {
|
|||||||
message::Message,
|
message::Message,
|
||||||
native_token::lamports_to_sol,
|
native_token::lamports_to_sol,
|
||||||
nonce::State as NonceState,
|
nonce::State as NonceState,
|
||||||
pubkey::{self, Pubkey},
|
pubkey::Pubkey,
|
||||||
rent::Rent,
|
rent::Rent,
|
||||||
rpc_port::DEFAULT_RPC_PORT_STR,
|
rpc_port::DEFAULT_RPC_PORT_STR,
|
||||||
signature::Signature,
|
signature::Signature,
|
||||||
slot_history,
|
slot_history,
|
||||||
stake::{self, state::StakeState},
|
stake::{self, state::StakeState},
|
||||||
system_instruction, system_program,
|
system_instruction,
|
||||||
sysvar::{
|
sysvar::{
|
||||||
self,
|
self,
|
||||||
slot_history::SlotHistory,
|
slot_history::SlotHistory,
|
||||||
@ -263,15 +263,6 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
|||||||
.takes_value(false)
|
.takes_value(false)
|
||||||
.help("Print timestamp (unix time + microseconds as in gettimeofday) before each line"),
|
.help("Print timestamp (unix time + microseconds as in gettimeofday) before each line"),
|
||||||
)
|
)
|
||||||
.arg(
|
|
||||||
Arg::with_name("lamports")
|
|
||||||
.long("lamports")
|
|
||||||
.value_name("NUMBER")
|
|
||||||
.takes_value(true)
|
|
||||||
.default_value("1")
|
|
||||||
.validator(is_amount)
|
|
||||||
.help("Number of lamports to transfer for each transaction"),
|
|
||||||
)
|
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("timeout")
|
Arg::with_name("timeout")
|
||||||
.short("t")
|
.short("t")
|
||||||
@ -516,7 +507,6 @@ pub fn parse_cluster_ping(
|
|||||||
default_signer: &DefaultSigner,
|
default_signer: &DefaultSigner,
|
||||||
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
wallet_manager: &mut Option<Arc<RemoteWalletManager>>,
|
||||||
) -> Result<CliCommandInfo, CliError> {
|
) -> Result<CliCommandInfo, CliError> {
|
||||||
let lamports = value_t_or_exit!(matches, "lamports", u64);
|
|
||||||
let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64));
|
let interval = Duration::from_secs(value_t_or_exit!(matches, "interval", u64));
|
||||||
let count = if matches.is_present("count") {
|
let count = if matches.is_present("count") {
|
||||||
Some(value_t_or_exit!(matches, "count", u64))
|
Some(value_t_or_exit!(matches, "count", u64))
|
||||||
@ -528,7 +518,6 @@ pub fn parse_cluster_ping(
|
|||||||
let print_timestamp = matches.is_present("print_timestamp");
|
let print_timestamp = matches.is_present("print_timestamp");
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::Ping {
|
command: CliCommand::Ping {
|
||||||
lamports,
|
|
||||||
interval,
|
interval,
|
||||||
count,
|
count,
|
||||||
timeout,
|
timeout,
|
||||||
@ -1359,7 +1348,6 @@ pub fn process_get_transaction_count(rpc_client: &RpcClient, _config: &CliConfig
|
|||||||
pub fn process_ping(
|
pub fn process_ping(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
config: &CliConfig,
|
config: &CliConfig,
|
||||||
lamports: u64,
|
|
||||||
interval: &Duration,
|
interval: &Duration,
|
||||||
count: &Option<u64>,
|
count: &Option<u64>,
|
||||||
timeout: &Duration,
|
timeout: &Duration,
|
||||||
@ -1380,7 +1368,7 @@ pub fn process_ping(
|
|||||||
let mut confirmation_time: VecDeque<u64> = VecDeque::with_capacity(1024);
|
let mut confirmation_time: VecDeque<u64> = VecDeque::with_capacity(1024);
|
||||||
|
|
||||||
let mut blockhash = rpc_client.get_latest_blockhash()?;
|
let mut blockhash = rpc_client.get_latest_blockhash()?;
|
||||||
let mut blockhash_transaction_count = 0;
|
let mut lamports = 0;
|
||||||
let mut blockhash_acquired = Instant::now();
|
let mut blockhash_acquired = Instant::now();
|
||||||
if let Some(fixed_blockhash) = fixed_blockhash {
|
if let Some(fixed_blockhash) = fixed_blockhash {
|
||||||
let blockhash_origin = if *fixed_blockhash != Hash::default() {
|
let blockhash_origin = if *fixed_blockhash != Hash::default() {
|
||||||
@ -1400,15 +1388,12 @@ pub fn process_ping(
|
|||||||
// Fetch a new blockhash every minute
|
// Fetch a new blockhash every minute
|
||||||
let new_blockhash = rpc_client.get_new_latest_blockhash(&blockhash)?;
|
let new_blockhash = rpc_client.get_new_latest_blockhash(&blockhash)?;
|
||||||
blockhash = new_blockhash;
|
blockhash = new_blockhash;
|
||||||
blockhash_transaction_count = 0;
|
lamports = 0;
|
||||||
blockhash_acquired = Instant::now();
|
blockhash_acquired = Instant::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
let seed =
|
let to = config.signers[0].pubkey();
|
||||||
&format!("{}{}", blockhash_transaction_count, blockhash)[0..pubkey::MAX_SEED_LEN];
|
lamports += 1;
|
||||||
let to = Pubkey::create_with_seed(&config.signers[0].pubkey(), seed, &system_program::id())
|
|
||||||
.unwrap();
|
|
||||||
blockhash_transaction_count += 1;
|
|
||||||
|
|
||||||
let build_message = |lamports| {
|
let build_message = |lamports| {
|
||||||
let ix = system_instruction::transfer(&config.signers[0].pubkey(), &to, lamports);
|
let ix = system_instruction::transfer(&config.signers[0].pubkey(), &to, lamports);
|
||||||
@ -2305,7 +2290,6 @@ mod tests {
|
|||||||
parse_command(&test_ping, &default_signer, &mut None).unwrap(),
|
parse_command(&test_ping, &default_signer, &mut None).unwrap(),
|
||||||
CliCommandInfo {
|
CliCommandInfo {
|
||||||
command: CliCommand::Ping {
|
command: CliCommand::Ping {
|
||||||
lamports: 1,
|
|
||||||
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),
|
||||||
|
Reference in New Issue
Block a user