Rename startAfter to before
This commit is contained in:
parent
a11f137810
commit
02c0981ecf
|
@ -231,7 +231,7 @@ pub enum CliCommand {
|
|||
TotalSupply,
|
||||
TransactionHistory {
|
||||
address: Pubkey,
|
||||
start_after: Option<Signature>,
|
||||
before: Option<Signature>,
|
||||
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
|
||||
|
||||
|
|
|
@ -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<CliCommandInfo, CliError> {
|
||||
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<Signature>,
|
||||
before: Option<Signature>,
|
||||
limit: usize,
|
||||
) -> ProcessResult {
|
||||
let results = rpc_client.get_confirmed_signatures_for_address2_with_config(
|
||||
address,
|
||||
start_after,
|
||||
before,
|
||||
Some(limit),
|
||||
)?;
|
||||
|
||||
|
|
|
@ -302,11 +302,11 @@ impl RpcClient {
|
|||
pub fn get_confirmed_signatures_for_address2_with_config(
|
||||
&self,
|
||||
address: &Pubkey,
|
||||
start_after: Option<Signature>,
|
||||
before: Option<Signature>,
|
||||
limit: Option<usize>,
|
||||
) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>> {
|
||||
let config = RpcGetConfirmedSignaturesForAddress2Config {
|
||||
start_after: start_after.map(|signature| signature.to_string()),
|
||||
before: before.map(|signature| signature.to_string()),
|
||||
limit,
|
||||
};
|
||||
|
||||
|
|
|
@ -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<String>, // Signature as base-58 string
|
||||
pub before: Option<String>, // Signature as base-58 string
|
||||
pub limit: Option<usize>,
|
||||
}
|
||||
|
|
|
@ -839,7 +839,7 @@ impl JsonRpcRequestProcessor {
|
|||
pub fn get_confirmed_signatures_for_address2(
|
||||
&self,
|
||||
address: Pubkey,
|
||||
start_after: Option<Signature>,
|
||||
before: Option<Signature>,
|
||||
limit: usize,
|
||||
) -> Result<Vec<RpcConfirmedTransactionStatusWithSignature>> {
|
||||
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<Slot> {
|
||||
|
|
|
@ -428,10 +428,8 @@ address backwards in time from the provided signature or most recent confirmed b
|
|||
#### Parameters:
|
||||
* `<string>` - account address as base-58 encoded string
|
||||
* `<object>` - (optional) Configuration object containing the following fields:
|
||||
* `startAfter: <string>` - (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: <string>` - (optional) start searching backwards from this transaction signature.
|
||||
If not provided the search starts from the top of the highest max confirmed block.
|
||||
* `limit: <number>` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000).
|
||||
|
||||
#### Results:
|
||||
|
|
|
@ -1927,7 +1927,7 @@ impl Blockstore {
|
|||
&self,
|
||||
address: Pubkey,
|
||||
highest_confirmed_root: Slot,
|
||||
start_after: Option<Signature>,
|
||||
before: Option<Signature>,
|
||||
limit: usize,
|
||||
) -> Result<Vec<ConfirmedTransactionStatusWithSignature>> {
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue