Rename startAfter to before
This commit is contained in:
parent
a11f137810
commit
02c0981ecf
|
@ -231,7 +231,7 @@ pub enum CliCommand {
|
||||||
TotalSupply,
|
TotalSupply,
|
||||||
TransactionHistory {
|
TransactionHistory {
|
||||||
address: Pubkey,
|
address: Pubkey,
|
||||||
start_after: Option<Signature>,
|
before: Option<Signature>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
},
|
},
|
||||||
// Nonce commands
|
// Nonce commands
|
||||||
|
@ -1871,9 +1871,9 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||||
CliCommand::TotalSupply => process_total_supply(&rpc_client, config),
|
CliCommand::TotalSupply => process_total_supply(&rpc_client, config),
|
||||||
CliCommand::TransactionHistory {
|
CliCommand::TransactionHistory {
|
||||||
address,
|
address,
|
||||||
start_after,
|
before,
|
||||||
limit,
|
limit,
|
||||||
} => process_transaction_history(&rpc_client, config, address, *start_after, *limit),
|
} => process_transaction_history(&rpc_client, config, address, *before, *limit),
|
||||||
|
|
||||||
// Nonce Commands
|
// Nonce Commands
|
||||||
|
|
||||||
|
|
|
@ -277,8 +277,8 @@ impl ClusterQuerySubCommands 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"),
|
||||||
|
@ -437,7 +437,7 @@ pub fn parse_transaction_history(
|
||||||
) -> Result<CliCommandInfo, CliError> {
|
) -> Result<CliCommandInfo, CliError> {
|
||||||
let address = pubkey_of_signer(matches, "address", wallet_manager)?.unwrap();
|
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(
|
Some(signature) => Some(
|
||||||
signature
|
signature
|
||||||
.parse()
|
.parse()
|
||||||
|
@ -450,7 +450,7 @@ pub fn parse_transaction_history(
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::TransactionHistory {
|
command: CliCommand::TransactionHistory {
|
||||||
address,
|
address,
|
||||||
start_after,
|
before,
|
||||||
limit,
|
limit,
|
||||||
},
|
},
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
|
@ -1311,12 +1311,12 @@ pub fn process_transaction_history(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
config: &CliConfig,
|
config: &CliConfig,
|
||||||
address: &Pubkey,
|
address: &Pubkey,
|
||||||
start_after: Option<Signature>,
|
before: Option<Signature>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
let results = rpc_client.get_confirmed_signatures_for_address2_with_config(
|
let results = rpc_client.get_confirmed_signatures_for_address2_with_config(
|
||||||
address,
|
address,
|
||||||
start_after,
|
before,
|
||||||
Some(limit),
|
Some(limit),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
@ -302,11 +302,11 @@ impl RpcClient {
|
||||||
pub fn get_confirmed_signatures_for_address2_with_config(
|
pub fn get_confirmed_signatures_for_address2_with_config(
|
||||||
&self,
|
&self,
|
||||||
address: &Pubkey,
|
address: &Pubkey,
|
||||||
start_after: Option<Signature>,
|
before: Option<Signature>,
|
||||||
limit: Option<usize>,
|
limit: Option<usize>,
|
||||||
) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>> {
|
) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>> {
|
||||||
let config = RpcGetConfirmedSignaturesForAddress2Config {
|
let config = RpcGetConfirmedSignaturesForAddress2Config {
|
||||||
start_after: start_after.map(|signature| signature.to_string()),
|
before: before.map(|signature| signature.to_string()),
|
||||||
limit,
|
limit,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,6 @@ pub enum RpcTokenAccountsFilter {
|
||||||
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RpcGetConfirmedSignaturesForAddress2Config {
|
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>,
|
pub limit: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -839,7 +839,7 @@ impl JsonRpcRequestProcessor {
|
||||||
pub fn get_confirmed_signatures_for_address2(
|
pub fn get_confirmed_signatures_for_address2(
|
||||||
&self,
|
&self,
|
||||||
address: Pubkey,
|
address: Pubkey,
|
||||||
start_after: Option<Signature>,
|
before: Option<Signature>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
) -> Result<Vec<RpcConfirmedTransactionStatusWithSignature>> {
|
) -> Result<Vec<RpcConfirmedTransactionStatusWithSignature>> {
|
||||||
if self.config.enable_rpc_transaction_history {
|
if self.config.enable_rpc_transaction_history {
|
||||||
|
@ -854,7 +854,7 @@ impl JsonRpcRequestProcessor {
|
||||||
.get_confirmed_signatures_for_address2(
|
.get_confirmed_signatures_for_address2(
|
||||||
address,
|
address,
|
||||||
highest_confirmed_root,
|
highest_confirmed_root,
|
||||||
start_after,
|
before,
|
||||||
limit,
|
limit,
|
||||||
)
|
)
|
||||||
.map_err(|err| Error::invalid_params(format!("{}", err)))?;
|
.map_err(|err| Error::invalid_params(format!("{}", err)))?;
|
||||||
|
@ -2162,8 +2162,8 @@ impl RpcSol for RpcSolImpl {
|
||||||
let address = verify_pubkey(address)?;
|
let address = verify_pubkey(address)?;
|
||||||
|
|
||||||
let config = config.unwrap_or_default();
|
let config = config.unwrap_or_default();
|
||||||
let start_after = if let Some(start_after) = config.start_after {
|
let before = if let Some(before) = config.before {
|
||||||
Some(verify_signature(&start_after)?)
|
Some(verify_signature(&before)?)
|
||||||
} else {
|
} else {
|
||||||
None
|
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> {
|
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:
|
#### Parameters:
|
||||||
* `<string>` - account address as base-58 encoded string
|
* `<string>` - account address as base-58 encoded string
|
||||||
* `<object>` - (optional) Configuration object containing the following fields:
|
* `<object>` - (optional) Configuration object containing the following fields:
|
||||||
* `startAfter: <string>` - (optional) start searching backwards from this transaction signature,
|
* `before: <string>` - (optional) start searching backwards from this transaction signature.
|
||||||
which must be a confirmed signature for the account
|
If not provided the search starts from the top of the highest max confirmed block.
|
||||||
address. If not provided the search starts from
|
|
||||||
the highest max confirmed block.
|
|
||||||
* `limit: <number>` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000).
|
* `limit: <number>` - (optional) maximum transaction signatures to return (between 1 and 1,000, default: 1,000).
|
||||||
|
|
||||||
#### Results:
|
#### Results:
|
||||||
|
|
|
@ -1927,7 +1927,7 @@ impl Blockstore {
|
||||||
&self,
|
&self,
|
||||||
address: Pubkey,
|
address: Pubkey,
|
||||||
highest_confirmed_root: Slot,
|
highest_confirmed_root: Slot,
|
||||||
start_after: Option<Signature>,
|
before: Option<Signature>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
) -> Result<Vec<ConfirmedTransactionStatusWithSignature>> {
|
) -> Result<Vec<ConfirmedTransactionStatusWithSignature>> {
|
||||||
datapoint_info!(
|
datapoint_info!(
|
||||||
|
@ -1940,12 +1940,12 @@ impl Blockstore {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Figure the `slot` to start listing signatures at, based on the ledger location of the
|
// 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.
|
// 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),
|
None => (highest_confirmed_root, None),
|
||||||
Some(start_after) => {
|
Some(before) => {
|
||||||
let transaction_status = self.get_transaction_status(start_after)?;
|
let transaction_status = self.get_transaction_status(before)?;
|
||||||
match transaction_status {
|
match transaction_status {
|
||||||
None => return Ok(vec![]),
|
None => return Ok(vec![]),
|
||||||
Some((slot, _)) => {
|
Some((slot, _)) => {
|
||||||
|
@ -1978,7 +1978,7 @@ impl Blockstore {
|
||||||
// not by block ordering
|
// not by block ordering
|
||||||
slot_signatures.sort();
|
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);
|
slot_signatures.truncate(pos + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6345,7 +6345,7 @@ pub mod tests {
|
||||||
assert_eq!(results[1], all1[i + 1]);
|
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
|
let results = blockstore
|
||||||
.get_confirmed_signatures_for_address2(
|
.get_confirmed_signatures_for_address2(
|
||||||
address0,
|
address0,
|
||||||
|
|
Loading…
Reference in New Issue