Skip to content

Commit

Permalink
rename height unwrap fn
Browse files Browse the repository at this point in the history
  • Loading branch information
yaahc committed Oct 30, 2020
1 parent 69fe187 commit b6b56ca
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion zebra-state/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum HashOrHeight {
impl HashOrHeight {
/// Unwrap the inner height or attempt to retrieve the height for a given
/// hash if one exists.
pub fn unwrap_height<F>(self, op: F) -> Option<block::Height>
pub fn height_or_else<F>(self, op: F) -> Option<block::Height>
where
F: FnOnce(block::Hash) -> Option<block::Height>,
{
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/service/memory_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ impl NonFinalizedState {
pub fn block(&self, hash_or_height: HashOrHeight) -> Option<Arc<Block>> {
let best_chain = self.best_chain()?;
let height =
hash_or_height.unwrap_height(|hash| best_chain.height_by_hash.get(&hash).cloned())?;
hash_or_height.height_or_else(|hash| best_chain.height_by_hash.get(&hash).cloned())?;

best_chain.blocks.get(&height).cloned()
}
Expand Down
2 changes: 1 addition & 1 deletion zebra-state/src/sled_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ impl FinalizedState {

/// Returns the given block if it exists.
pub fn block(&self, hash_or_height: HashOrHeight) -> Option<Arc<Block>> {
let height = hash_or_height.unwrap_height(|hash| self.height_by_hash.zs_get(&hash))?;
let height = hash_or_height.height_or_else(|hash| self.height_by_hash.zs_get(&hash))?;

self.block_by_height.zs_get(&height)
}
Expand Down

0 comments on commit b6b56ca

Please sign in to comment.