get_confirmed_block: expect() less

This commit is contained in:
Michael Vines 2020-02-12 17:53:00 -07:00
parent 1c97b31eaf
commit ab475e4849

View File

@ -1387,9 +1387,13 @@ impl Blockstore {
let encoding = encoding.unwrap_or(RpcTransactionEncoding::Json);
if self.is_root(slot) {
let slot_meta_cf = self.db.column::<cf::SlotMeta>();
let slot_meta = slot_meta_cf
.get(slot)?
.expect("Rooted slot must exist in SlotMeta");
let slot_meta = match slot_meta_cf.get(slot)? {
Some(slot_meta) => slot_meta,
None => {
info!("SlotMeta not found for rooted slot {}", slot);
return Err(BlockstoreError::SlotCleanedUp);
}
};
let slot_entries = self.get_slot_entries(slot, 0, None)?;
if !slot_entries.is_empty() {
@ -1407,11 +1411,7 @@ impl Blockstore {
let blockhash = get_last_hash(slot_entries.iter())
.unwrap_or_else(|| panic!("Rooted slot {:?} must have blockhash", slot));
let rewards = self
.rewards_cf
.get(slot)
.expect("Expect rewards get to succeed")
.unwrap_or_else(|| vec![]);
let rewards = self.rewards_cf.get(slot)?.unwrap_or_else(|| vec![]);
let block = RpcConfirmedBlock {
previous_blockhash: previous_blockhash.to_string(),