From de479ebda9651090fa4ae827690491db9b3077f2 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 20 May 2020 15:32:21 -0700 Subject: [PATCH] transaction-history now searches over the entire history by default (#10145) (#10153) automerge --- cli/src/cli.rs | 4 ++-- cli/src/cluster_query.rs | 29 ++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 312e01b841..a14247d4ae 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -244,8 +244,8 @@ pub enum CliCommand { }, TransactionHistory { address: Pubkey, - end_slot: Option, // None == latest slot - slot_limit: u64, + end_slot: Option, // None == latest slot + slot_limit: Option, // None == search full history }, // Nonce commands AuthorizeNonceAccount { diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index 0b3a0a984c..82556e6ab3 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -457,8 +457,7 @@ pub fn parse_transaction_history( ) -> Result { let address = pubkey_of_signer(matches, "address", wallet_manager)?.unwrap(); let end_slot = value_t!(matches, "end_slot", Slot).ok(); - let slot_limit = value_t!(matches, "limit", u64) - .unwrap_or(MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE); + let slot_limit = value_t!(matches, "limit", u64).ok(); Ok(CliCommandInfo { command: CliCommand::TransactionHistory { @@ -1263,7 +1262,7 @@ pub fn process_transaction_history( rpc_client: &RpcClient, address: &Pubkey, end_slot: Option, // None == use latest slot - slot_limit: u64, + slot_limit: Option, ) -> ProcessResult { let end_slot = { if let Some(end_slot) = end_slot { @@ -1272,18 +1271,30 @@ pub fn process_transaction_history( rpc_client.get_slot_with_commitment(CommitmentConfig::max())? } }; - let start_slot = end_slot.saturating_sub(slot_limit); + let mut start_slot = match slot_limit { + Some(slot_limit) => end_slot.saturating_sub(slot_limit), + None => rpc_client.minimum_ledger_slot()?, + }; println!( "Transactions affecting {} within slots [{},{}]", address, start_slot, end_slot ); - let signatures = - rpc_client.get_confirmed_signatures_for_address(address, start_slot, end_slot)?; - for signature in &signatures { - println!("{}", signature); + + let mut transaction_count = 0; + while start_slot < end_slot { + let signatures = rpc_client.get_confirmed_signatures_for_address( + address, + start_slot, + (start_slot + MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE).min(end_slot), + )?; + for signature in &signatures { + println!("{}", signature); + } + transaction_count += signatures.len(); + start_slot += MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE; } - Ok(format!("{} transactions found", signatures.len(),)) + Ok(format!("{} transactions found", transaction_count)) } #[cfg(test)]