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

* Plug getConfirmedSignaturesForAddress2 into bigtable storage

(cherry picked from commit 4222932e08)

# Conflicts:
#	ledger-tool/src/bigtable.rs
#	storage-bigtable/src/lib.rs

* 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:49:30 +00:00
committed by GitHub
parent 0a4a3fd37e
commit 798a6db915
4 changed files with 67 additions and 43 deletions

View File

@@ -808,8 +808,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
@@ -818,7 +818,7 @@ impl JsonRpcRequestProcessor {
.unwrap()
.highest_confirmed_slot();
let results = self
let mut results = self
.blockstore
.get_confirmed_signatures_for_address2(
address,
@@ -828,6 +828,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![])