From aa02c72dfb683e3c3db87083724f4e5fc3a90a33 Mon Sep 17 00:00:00 2001 From: viquezclaudio Date: Thu, 13 Jun 2024 19:23:42 +0300 Subject: [PATCH] Fix some clippy warnings --- blockchain/src/history/history_store.rs | 13 ++----------- blockchain/src/history/validity_store.rs | 12 ++---------- consensus/src/sync/light/sync.rs | 2 -- consensus/src/sync/light/validity_window.rs | 1 - 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/blockchain/src/history/history_store.rs b/blockchain/src/history/history_store.rs index a651502747..055d67fa16 100644 --- a/blockchain/src/history/history_store.rs +++ b/blockchain/src/history/history_store.rs @@ -1272,17 +1272,8 @@ impl HistoryInterface for HistoryStore { let mut cursor = txn.cursor(&self.last_leaf_table); - let first = if let Some((key, _)) = cursor.first::() { - key - } else { - 0 - }; - - let last = if let Some((key, _)) = cursor.last::() { - key - } else { - 0 - }; + let first = cursor.first::().unwrap_or_default().0; + let last = cursor.last::().unwrap_or_default().0; (first, last) } diff --git a/blockchain/src/history/validity_store.rs b/blockchain/src/history/validity_store.rs index 77eef7cbee..1c2c890fff 100644 --- a/blockchain/src/history/validity_store.rs +++ b/blockchain/src/history/validity_store.rs @@ -61,11 +61,7 @@ impl ValidityStore { // Initialize the cursor for the database. let mut cursor = db_tx.cursor(&self.block_txns); - if let Some((key, _)) = cursor.first::() { - key - } else { - 0 - } + cursor.first::().unwrap_or_default().0 } /// Obtains the last block number stored in the validity store. @@ -73,11 +69,7 @@ impl ValidityStore { // Initialize the cursor for the database. let mut cursor = db_tx.cursor(&self.block_txns); - if let Some((key, _)) = cursor.last::() { - key - } else { - 0 - } + cursor.last::().unwrap_or_default().0 } /// Adds a transaction hash to the validity store diff --git a/consensus/src/sync/light/sync.rs b/consensus/src/sync/light/sync.rs index ffe3aee777..3d7fe516b2 100644 --- a/consensus/src/sync/light/sync.rs +++ b/consensus/src/sync/light/sync.rs @@ -62,8 +62,6 @@ pub struct ValidityChunkRequest { pub root_hash: Blake2bHash, /// The chunk index that was requested. pub chunk_index: u32, - /// Validity start block number that we are syncing with this peer - pub validity_start: u32, /// Flag to indicate if there is an election block within the validity window pub election_in_window: bool, /// Number of items in the previous requested chunk (for cases where we adopt a new macro head) diff --git a/consensus/src/sync/light/validity_window.rs b/consensus/src/sync/light/validity_window.rs index c6637a99be..d13ec7f16b 100644 --- a/consensus/src/sync/light/validity_window.rs +++ b/consensus/src/sync/light/validity_window.rs @@ -114,7 +114,6 @@ impl LightMacroSync { verifier_block_number, root_hash, chunk_index, - validity_start: validity_window_start, election_in_window, last_chunk_items, });