Skip to content

Commit

Permalink
Blockstore: only return block times for rooted slots (solana-labs#33871)
Browse files Browse the repository at this point in the history
* Add Blockstore::get_rooted_block_time method and use in RPC

* Un-pub get_block_time
  • Loading branch information
CriesofCarrots authored Oct 26, 2023
1 parent 22503f0 commit 7048e72
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1962,12 +1962,23 @@ impl Blockstore {
}
}

pub fn get_block_time(&self, slot: Slot) -> Result<Option<UnixTimestamp>> {
datapoint_info!("blockstore-rpc-api", ("method", "get_block_time", String));
fn get_block_time(&self, slot: Slot) -> Result<Option<UnixTimestamp>> {
let _lock = self.check_lowest_cleanup_slot(slot)?;
self.blocktime_cf.get(slot)
}

pub fn get_rooted_block_time(&self, slot: Slot) -> Result<Option<UnixTimestamp>> {
datapoint_info!(
"blockstore-rpc-api",
("method", "get_rooted_block_time", String)
);
let _lock = self.check_lowest_cleanup_slot(slot)?;
if self.is_root(slot) {
return self.blocktime_cf.get(slot);
}
Err(BlockstoreError::SlotNotRooted)
}

pub fn cache_block_time(&self, slot: Slot, timestamp: UnixTimestamp) -> Result<()> {
self.blocktime_cf.put(slot, &timestamp)
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ impl JsonRpcRequestProcessor {
.unwrap()
.highest_super_majority_root()
{
let result = self.blockstore.get_block_time(slot);
let result = self.blockstore.get_rooted_block_time(slot);
self.check_blockstore_root(&result, slot)?;
if result.is_err() || matches!(result, Ok(None)) {
if let Some(bigtable_ledger_storage) = &self.bigtable_ledger_storage {
Expand Down

0 comments on commit 7048e72

Please sign in to comment.