Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Commit

Permalink
Add block_exists utility function
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Dec 4, 2018
1 parent 1627d93 commit cf462a8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions storage/src/lib.rs
Expand Up @@ -261,6 +261,14 @@ pub fn block_read(storage: &Storage, hash: &HeaderHash) -> Result<RawBlock> {
block_read_location(storage, &block_location(storage, hash)?, hash)
}

pub fn block_exists(storage: &Storage, hash: &HeaderHash) -> Result<bool> {
match block_location(storage, hash) {
Ok(_) => Ok(true),
Err(Error::HashNotFound(_)) => Ok(false),
Err(err) => Err(err),
}
}

enum ReverseSearch {
Continue,
Found,
Expand Down

0 comments on commit cf462a8

Please sign in to comment.