Rpc: Add custom error for BigTable data not found (bp #14762) (#14764)

* Rpc: Add custom error for BigTable data not found (#14762)

* Expose not-found bigtable error

* Add custom rpc error for bigtable data not found

* Return custom rpc error when bigtable block is not found

* Generalize long-term storage

(cherry picked from commit 71e9958e06)

# Conflicts:
#	client/src/rpc_custom_error.rs

* Fix conflicts

Co-authored-by: Tyera Eulberg <teulberg@gmail.com>
Co-authored-by: Tyera Eulberg <tyera@solana.com>
This commit is contained in:
mergify[bot]
2021-01-22 06:09:22 +00:00
committed by GitHub
parent e4068cb1bc
commit 1041532c0e
3 changed files with 48 additions and 7 deletions

View File

@@ -334,7 +334,11 @@ impl LedgerStorage {
"blocks",
slot_to_key(slot),
)
.await?;
.await
.map_err(|err| match err {
bigtable::Error::RowNotFound => Error::BlockNotFound(slot),
_ => err.into(),
})?;
Ok(match block_cell_data {
bigtable::CellData::Bincode(block) => block.into(),
bigtable::CellData::Protobuf(block) => block.try_into().map_err(|_err| {
@@ -347,7 +351,11 @@ impl LedgerStorage {
let mut bigtable = self.connection.client();
let transaction_info = bigtable
.get_bincode_cell::<TransactionInfo>("tx", signature.to_string())
.await?;
.await
.map_err(|err| match err {
bigtable::Error::RowNotFound => Error::SignatureNotFound,
_ => err.into(),
})?;
Ok(transaction_info.into())
}
@@ -361,7 +369,11 @@ impl LedgerStorage {
// Figure out which block the transaction is located in
let TransactionInfo { slot, index, .. } = bigtable
.get_bincode_cell("tx", signature.to_string())
.await?;
.await
.map_err(|err| match err {
bigtable::Error::RowNotFound => Error::SignatureNotFound,
_ => err.into(),
})?;
// Load the block and return the transaction
let block = self.get_confirmed_block(slot).await?;