after -> before

This commit is contained in:
Michael Vines
2020-08-05 12:26:37 -07:00
parent 22c46ebf96
commit 227ea934ff
2 changed files with 13 additions and 13 deletions

View File

@ -309,13 +309,13 @@ async fn confirm(signature: &Signature, verbose: bool) -> Result<(), Box<dyn std
pub async fn transaction_history( pub async fn transaction_history(
address: &Pubkey, address: &Pubkey,
limit: usize, limit: usize,
start_after: Option<&Signature>, before: Option<&Signature>,
verbose: bool, verbose: bool,
) -> Result<(), Box<dyn std::error::Error>> { ) -> Result<(), Box<dyn std::error::Error>> {
let bigtable = solana_storage_bigtable::LedgerStorage::new(true).await?; let bigtable = solana_storage_bigtable::LedgerStorage::new(true).await?;
let results = bigtable let results = bigtable
.get_confirmed_signatures_for_address(address, start_after, limit) .get_confirmed_signatures_for_address(address, before, limit)
.await?; .await?;
for (signature, slot, memo, err) in results { for (signature, slot, memo, err) in results {
@ -466,8 +466,8 @@ impl BigTableSubCommand for App<'_, '_> {
.help("Maximum number of transaction signatures to return"), .help("Maximum number of transaction signatures to return"),
) )
.arg( .arg(
Arg::with_name("after") Arg::with_name("before")
.long("after") .long("before")
.value_name("TRANSACTION_SIGNATURE") .value_name("TRANSACTION_SIGNATURE")
.takes_value(true) .takes_value(true)
.help("Start with the first signature older than this one"), .help("Start with the first signature older than this one"),
@ -526,15 +526,15 @@ pub fn bigtable_process_command(ledger_path: &Path, matches: &ArgMatches<'_>) {
("transaction-history", Some(arg_matches)) => { ("transaction-history", Some(arg_matches)) => {
let address = pubkey_of(arg_matches, "address").unwrap(); let address = pubkey_of(arg_matches, "address").unwrap();
let limit = value_t_or_exit!(arg_matches, "limit", usize); let limit = value_t_or_exit!(arg_matches, "limit", usize);
let after = arg_matches let before = arg_matches
.value_of("after") .value_of("before")
.map(|signature| signature.parse().expect("Invalid signature")); .map(|signature| signature.parse().expect("Invalid signature"));
let verbose = arg_matches.is_present("verbose"); let verbose = arg_matches.is_present("verbose");
runtime.block_on(transaction_history( runtime.block_on(transaction_history(
&address, &address,
limit, limit,
after.as_ref(), before.as_ref(),
verbose, verbose,
)) ))
} }

View File

@ -358,23 +358,23 @@ impl LedgerStorage {
/// Get confirmed signatures for the provided address, in descending ledger order /// Get confirmed signatures for the provided address, in descending ledger order
/// ///
/// address: address to search for /// address: address to search for
/// start_after_signature: start with the first signature older than this one /// before_signature: start with the first signature older than this one
/// limit: stop after this many signatures. /// limit: stop after this many signatures.
pub async fn get_confirmed_signatures_for_address( pub async fn get_confirmed_signatures_for_address(
&self, &self,
address: &Pubkey, address: &Pubkey,
start_after_signature: Option<&Signature>, before_signature: Option<&Signature>,
limit: usize, limit: usize,
) -> Result<Vec<(Signature, Slot, Option<String>, Option<TransactionError>)>> { ) -> Result<Vec<(Signature, Slot, Option<String>, Option<TransactionError>)>> {
let mut bigtable = self.connection.client(); let mut bigtable = self.connection.client();
let address_prefix = format!("{}/", address); let address_prefix = format!("{}/", address);
// Figure out where to start listing from based on `start_after_signature` // Figure out where to start listing from based on `before_signature`
let (first_slot, mut first_transaction_index) = match start_after_signature { let (first_slot, mut first_transaction_index) = match before_signature {
None => (Slot::MAX, 0), None => (Slot::MAX, 0),
Some(start_after_signature) => { Some(before_signature) => {
let TransactionInfo { slot, index, .. } = bigtable let TransactionInfo { slot, index, .. } = bigtable
.get_bincode_cell("tx", start_after_signature.to_string()) .get_bincode_cell("tx", before_signature.to_string())
.await?; .await?;
(slot, index + 1) (slot, index + 1)