From d8bc96c1501e8343ffd0ad4fbcec0590ce1c876f Mon Sep 17 00:00:00 2001 From: Sergey Boyko Date: Thu, 2 Mar 2023 12:15:25 +0100 Subject: [PATCH] Fix PR issues --- .../wasm/indexeddb_block_header_storage.rs | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/mm2src/coins/utxo/utxo_block_header_storage/wasm/indexeddb_block_header_storage.rs b/mm2src/coins/utxo/utxo_block_header_storage/wasm/indexeddb_block_header_storage.rs index 5b0b4b0f6c..3e19792548 100644 --- a/mm2src/coins/utxo/utxo_block_header_storage/wasm/indexeddb_block_header_storage.rs +++ b/mm2src/coins/utxo/utxo_block_header_storage/wasm/indexeddb_block_header_storage.rs @@ -195,14 +195,13 @@ impl BlockHeaderStorageOps for IDBBlockHeadersStorage { .await .map_err(|err| BlockHeaderStorageError::get_err(&ticker, err.to_string()))?; - if let Some((_item_id, item)) = maybe_item { - let height = item - .height - .to_u64() - .ok_or_else(|| BlockHeaderStorageError::get_err(&ticker, "height is too large".to_string()))?; - return Ok(Some(height)); - } - Ok(None) + maybe_item + .map(|(_, item)| { + item.height + .to_u64() + .ok_or_else(|| BlockHeaderStorageError::get_err(&ticker, "height is too large".to_string())) + }) + .transpose() } async fn get_last_block_header_with_non_max_bits( @@ -292,14 +291,13 @@ impl BlockHeaderStorageOps for IDBBlockHeadersStorage { .await .map_err(|err| BlockHeaderStorageError::get_err(&ticker, err.to_string()))?; - if let Some((_item_id, header)) = maybe_item { - let height = header - .height - .to_i64() - .ok_or_else(|| BlockHeaderStorageError::get_err(&ticker, "height is too large".to_string()))?; - return Ok(Some(height)); - } - Ok(None) + maybe_item + .map(|(_, item)| { + item.height + .to_i64() + .ok_or_else(|| BlockHeaderStorageError::get_err(&ticker, "height is too large".to_string())) + }) + .transpose() } async fn remove_headers_up_to_height(&self, to_height: u64) -> Result<(), BlockHeaderStorageError> {