Skip to content

Commit

Permalink
Make the block method docs consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Mar 15, 2022
1 parent 0cf5079 commit c536e0d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions zebra-state/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,8 @@ impl StateService {
Some(tip.0 - height.0)
}

/// Return the block identified by either its `height` or `hash`,
/// if it exists in the current best chain.
/// Returns the [`Block`] with [`Hash`](zebra_chain::block::Hash) or
/// [`Height`](zebra_chain::block::Height), if it exists in the current best chain.
pub fn best_block(&self, hash_or_height: HashOrHeight) -> Option<Arc<Block>> {
read::block(self.mem.best_chain(), self.disk.db(), hash_or_height)
}
Expand Down
3 changes: 2 additions & 1 deletion zebra-state/src/service/finalized_state/zebra_db/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ impl ZebraDb {
self.db.zs_get(height_by_hash, &hash)
}

/// Returns the given block if it exists.
/// Returns the [`Block`] with [`Hash`](zebra_chain::block::Hash) or
/// [`Height`](zebra_chain::block::Height), if it exists in the finalized chain.
pub fn block(&self, hash_or_height: HashOrHeight) -> Option<Arc<Block>> {
let height_by_hash = self.db.cf_handle("height_by_hash").unwrap();
let block_by_height = self.db.cf_handle("block_by_height").unwrap();
Expand Down
3 changes: 2 additions & 1 deletion zebra-state/src/service/non_finalized_state/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ impl Chain {
Ok(Some(forked))
}

/// Returns the [`ContextuallyValidBlock`] at a given height or hash in this chain.
/// Returns the [`ContextuallyValidBlock`] with [`Hash`](zebra_chain::block::Hash) or
/// [`Height`](zebra_chain::block::Height), if it exists in this chain.
pub fn block(&self, hash_or_height: HashOrHeight) -> Option<&ContextuallyValidBlock> {
let height =
hash_or_height.height_or_else(|hash| self.height_by_hash.get(&hash).cloned())?;
Expand Down

0 comments on commit c536e0d

Please sign in to comment.