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
This commit is contained in:
Tyera Eulberg
2021-01-21 21:40:47 -07:00
committed by GitHub
parent 12410541a4
commit 71e9958e06
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?;