From cf462a82740086f85a074bed85918eaa5eaa7a68 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 4 Dec 2018 10:48:44 +0100 Subject: [PATCH] Add block_exists utility function --- storage/src/lib.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/storage/src/lib.rs b/storage/src/lib.rs index 8b59f506a..456dde020 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -261,6 +261,14 @@ pub fn block_read(storage: &Storage, hash: &HeaderHash) -> Result { block_read_location(storage, &block_location(storage, hash)?, hash) } +pub fn block_exists(storage: &Storage, hash: &HeaderHash) -> Result { + match block_location(storage, hash) { + Ok(_) => Ok(true), + Err(Error::HashNotFound(_)) => Ok(false), + Err(err) => Err(err), + } +} + enum ReverseSearch { Continue, Found,