From 02c0981ecfb26553ef3f7e279e08c96a6fe2d250 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 5 Aug 2020 11:30:21 -0700 Subject: [PATCH] Rename startAfter to before --- cli/src/cli.rs | 6 +++--- cli/src/cluster_query.rs | 12 ++++++------ client/src/rpc_client.rs | 4 ++-- client/src/rpc_config.rs | 2 +- core/src/rpc.rs | 10 +++++----- docs/src/apps/jsonrpc-api.md | 6 ++---- ledger/src/blockstore.rs | 14 +++++++------- 7 files changed, 26 insertions(+), 28 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 695e645de..1755fd163 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -231,7 +231,7 @@ pub enum CliCommand { TotalSupply, TransactionHistory { address: Pubkey, - start_after: Option, + before: Option, limit: usize, }, // Nonce commands @@ -1871,9 +1871,9 @@ pub fn process_command(config: &CliConfig) -> ProcessResult { CliCommand::TotalSupply => process_total_supply(&rpc_client, config), CliCommand::TransactionHistory { address, - start_after, + before, limit, - } => process_transaction_history(&rpc_client, config, address, *start_after, *limit), + } => process_transaction_history(&rpc_client, config, address, *before, *limit), // Nonce Commands diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index 2f2e75a7d..d578c7823 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -277,8 +277,8 @@ impl ClusterQuerySubCommands for App<'_, '_> { .help("Maximum number of transaction signatures to return"), ) .arg( - Arg::with_name("after") - .long("after") + Arg::with_name("before") + .long("before") .value_name("TRANSACTION_SIGNATURE") .takes_value(true) .help("Start with the first signature older than this one"), @@ -437,7 +437,7 @@ pub fn parse_transaction_history( ) -> Result { let address = pubkey_of_signer(matches, "address", wallet_manager)?.unwrap(); - let start_after = match matches.value_of("after") { + let before = match matches.value_of("before") { Some(signature) => Some( signature .parse() @@ -450,7 +450,7 @@ pub fn parse_transaction_history( Ok(CliCommandInfo { command: CliCommand::TransactionHistory { address, - start_after, + before, limit, }, signers: vec![], @@ -1311,12 +1311,12 @@ pub fn process_transaction_history( rpc_client: &RpcClient, config: &CliConfig, address: &Pubkey, - start_after: Option, + before: Option, limit: usize, ) -> ProcessResult { let results = rpc_client.get_confirmed_signatures_for_address2_with_config( address, - start_after, + before, Some(limit), )?; diff --git a/client/src/rpc_client.rs b/client/src/rpc_client.rs index bd9550af7..fefbbab6a 100644 --- a/client/src/rpc_client.rs +++ b/client/src/rpc_client.rs @@ -302,11 +302,11 @@ impl RpcClient { pub fn get_confirmed_signatures_for_address2_with_config( &self, address: &Pubkey, - start_after: Option, + before: Option, limit: Option, ) -> ClientResult> { let config = RpcGetConfirmedSignaturesForAddress2Config { - start_after: start_after.map(|signature| signature.to_string()), + before: before.map(|signature| signature.to_string()), limit, }; diff --git a/client/src/rpc_config.rs b/client/src/rpc_config.rs index f3d674308..5722f1185 100644 --- a/client/src/rpc_config.rs +++ b/client/src/rpc_config.rs @@ -69,6 +69,6 @@ pub enum RpcTokenAccountsFilter { #[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct RpcGetConfirmedSignaturesForAddress2Config { - pub start_after: Option, // Signature as base-58 string + pub before: Option, // Signature as base-58 string pub limit: Option, } diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 2129d6146..e2589779d 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -839,7 +839,7 @@ impl JsonRpcRequestProcessor { pub fn get_confirmed_signatures_for_address2( &self, address: Pubkey, - start_after: Option, + before: Option, limit: usize, ) -> Result> { if self.config.enable_rpc_transaction_history { @@ -854,7 +854,7 @@ impl JsonRpcRequestProcessor { .get_confirmed_signatures_for_address2( address, highest_confirmed_root, - start_after, + before, limit, ) .map_err(|err| Error::invalid_params(format!("{}", err)))?; @@ -2162,8 +2162,8 @@ impl RpcSol for RpcSolImpl { let address = verify_pubkey(address)?; let config = config.unwrap_or_default(); - let start_after = if let Some(start_after) = config.start_after { - Some(verify_signature(&start_after)?) + let before = if let Some(before) = config.before { + Some(verify_signature(&before)?) } else { None }; @@ -2178,7 +2178,7 @@ impl RpcSol for RpcSolImpl { ))); } - meta.get_confirmed_signatures_for_address2(address, start_after, limit) + meta.get_confirmed_signatures_for_address2(address, before, limit) } fn get_first_available_block(&self, meta: Self::Metadata) -> Result { diff --git a/docs/src/apps/jsonrpc-api.md b/docs/src/apps/jsonrpc-api.md index 11428dbb1..3dcb23d52 100644 --- a/docs/src/apps/jsonrpc-api.md +++ b/docs/src/apps/jsonrpc-api.md @@ -428,10 +428,8 @@ address backwards in time from the provided signature or most recent confirmed b #### Parameters: * `` - account address as base-58 encoded string * `` - (optional) Configuration object containing the following fields: - * `startAfter: ` - (optional) start searching backwards from this transaction signature, - which must be a confirmed signature for the account - address. If not provided the search starts from - the highest max confirmed block. + * `before: ` - (optional) start searching backwards from this transaction signature. + If not provided the search starts from the top of the highest max confirmed block. * `limit: ` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000). #### Results: diff --git a/ledger/src/blockstore.rs b/ledger/src/blockstore.rs index b64623e6f..a81b28272 100644 --- a/ledger/src/blockstore.rs +++ b/ledger/src/blockstore.rs @@ -1927,7 +1927,7 @@ impl Blockstore { &self, address: Pubkey, highest_confirmed_root: Slot, - start_after: Option, + before: Option, limit: usize, ) -> Result> { datapoint_info!( @@ -1940,12 +1940,12 @@ impl Blockstore { ); // Figure the `slot` to start listing signatures at, based on the ledger location of the - // `start_after` signature if present. Also generate a HashSet of signatures that should + // `before` signature if present. Also generate a HashSet of signatures that should // be excluded from the results. - let (mut slot, mut excluded_signatures) = match start_after { + let (mut slot, mut excluded_signatures) = match before { None => (highest_confirmed_root, None), - Some(start_after) => { - let transaction_status = self.get_transaction_status(start_after)?; + Some(before) => { + let transaction_status = self.get_transaction_status(before)?; match transaction_status { None => return Ok(vec![]), Some((slot, _)) => { @@ -1978,7 +1978,7 @@ impl Blockstore { // not by block ordering slot_signatures.sort(); - if let Some(pos) = slot_signatures.iter().position(|&x| x == start_after) { + if let Some(pos) = slot_signatures.iter().position(|&x| x == before) { slot_signatures.truncate(pos + 1); } @@ -6345,7 +6345,7 @@ pub mod tests { assert_eq!(results[1], all1[i + 1]); } - // A search for address 0 with a `start_after` signature from address1 should also work + // A search for address 0 with a `before` signature from address1 should also work let results = blockstore .get_confirmed_signatures_for_address2( address0,