RPC: Plug getConfirmedSignaturesForAddress2 into bigtable storage (bp #11395) (#11406)

* Plug getConfirmedSignaturesForAddress2 into bigtable storage

(cherry picked from commit 4222932e08)

* Upgrade help description

(cherry picked from commit 9abb7db5f8)

Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
mergify[bot]
2020-08-06 07:14:46 +00:00
committed by GitHub
parent 5841e4d665
commit 1a42a40492
4 changed files with 67 additions and 43 deletions

View File

@@ -839,8 +839,8 @@ impl JsonRpcRequestProcessor {
pub fn get_confirmed_signatures_for_address2(
&self,
address: Pubkey,
before: Option<Signature>,
limit: usize,
mut before: Option<Signature>,
mut limit: usize,
) -> Result<Vec<RpcConfirmedTransactionStatusWithSignature>> {
if self.config.enable_rpc_transaction_history {
let highest_confirmed_root = self
@@ -849,7 +849,7 @@ impl JsonRpcRequestProcessor {
.unwrap()
.highest_confirmed_root();
let results = self
let mut results = self
.blockstore
.get_confirmed_signatures_for_address2(
address,
@@ -859,6 +859,27 @@ impl JsonRpcRequestProcessor {
)
.map_err(|err| Error::invalid_params(format!("{}", err)))?;
if results.len() < limit {
if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
if !results.is_empty() {
limit -= results.len();
before = results.last().map(|x| x.signature);
}
let mut bigtable_results = self
.runtime_handle
.block_on(
bigtable_ledger_storage.get_confirmed_signatures_for_address(
&address,
before.as_ref(),
limit,
),
)
.map_err(|err| Error::invalid_params(format!("{}", err)))?;
results.append(&mut bigtable_results)
}
}
Ok(results.into_iter().map(|x| x.into()).collect())
} else {
Ok(vec![])