Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyera Eulberg committed May 27, 2021
1 parent 68cf002 commit 060b995
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,8 @@ impl JsonRpcRequestProcessor {
|| confirmed_block.block_height.is_none()
{
let r_bank_forks = self.bank_forks.read().unwrap();
if let Some(bank) = r_bank_forks.get(slot) {
let bank = r_bank_forks.get(slot).cloned();
if let Some(bank) = bank {
if confirmed_block.block_time.is_none() {
confirmed_block.block_time = Some(bank.clock().unix_timestamp);
}
Expand Down
16 changes: 6 additions & 10 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1776,11 +1776,7 @@ impl Blockstore {
}

pub fn cache_block_time(&self, slot: Slot, timestamp: UnixTimestamp) -> Result<()> {
if self.get_block_time(slot).unwrap_or_default().is_none() {
self.blocktime_cf.put(slot, &timestamp)
} else {
Ok(())
}
self.blocktime_cf.put(slot, &timestamp)
}

pub fn get_block_height(&self, slot: Slot) -> Result<Option<u64>> {
Expand All @@ -1798,11 +1794,7 @@ impl Blockstore {
}

pub fn cache_block_height(&self, slot: Slot, block_height: u64) -> Result<()> {
if self.get_block_height(slot).unwrap_or_default().is_none() {
self.block_height_cf.put(slot, &block_height)
} else {
Ok(())
}
self.block_height_cf.put(slot, &block_height)
}

pub fn get_first_available_block(&self) -> Result<Slot> {
Expand Down Expand Up @@ -1882,6 +1874,10 @@ impl Blockstore {
.get_protobuf_or_bincode::<StoredExtendedRewards>(slot)?
.unwrap_or_default()
.into();

// The Blocktime and BlockHeight column families are updated asynchronously; they
// may not be written by the time the complete slot entries are available. In this
// case, these fields will be `None`.
let block_time = self.blocktime_cf.get(slot)?;
let block_height = self.block_height_cf.get(slot)?;

Expand Down

0 comments on commit 060b995

Please sign in to comment.