From 8e8e55d6708a7c6980e2e84ab42062b52b7d6abb Mon Sep 17 00:00:00 2001 From: Enzo Cioppettini Date: Tue, 1 Jun 2021 13:34:50 -0300 Subject: [PATCH] bunch of clippy lints --- explorer/src/db/indexing.rs | 5 +---- explorer/src/db/mod.rs | 2 +- explorer/src/db/persistent_sequence.rs | 4 ++++ explorer/src/main.rs | 4 ++-- explorer/src/settings.rs | 8 ++++---- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/explorer/src/db/indexing.rs b/explorer/src/db/indexing.rs index afd5b7f73f..37d732bc3e 100644 --- a/explorer/src/db/indexing.rs +++ b/explorer/src/db/indexing.rs @@ -152,10 +152,7 @@ impl ExplorerBlock { /// and mapping the account inputs to addresses with the given discrimination /// This function relies on the given block to be validated previously, and will panic /// otherwise - pub fn resolve_from<'a>( - block: &Block, - context: ExplorerBlockBuildingContext<'a>, - ) -> ExplorerBlock { + pub fn resolve_from(block: &Block, context: ExplorerBlockBuildingContext) -> ExplorerBlock { let fragments = block.contents.iter(); let id = block.id(); let chain_length = block.chain_length(); diff --git a/explorer/src/db/mod.rs b/explorer/src/db/mod.rs index 5dc2f7dfc6..81788a6d9b 100644 --- a/explorer/src/db/mod.rs +++ b/explorer/src/db/mod.rs @@ -129,9 +129,9 @@ impl ExplorerDb { let initial_state = State { transactions, blocks, + addresses, epochs, chain_lengths, - addresses, stake_pool_data, stake_pool_blocks, vote_plans, diff --git a/explorer/src/db/persistent_sequence.rs b/explorer/src/db/persistent_sequence.rs index 4295b56cbb..dcfbf613c8 100644 --- a/explorer/src/db/persistent_sequence.rs +++ b/explorer/src/db/persistent_sequence.rs @@ -32,6 +32,10 @@ impl PersistentSequence { pub fn len(&self) -> u64 { self.len } + + pub fn is_empty(&self) -> bool { + self.len() != 0 + } } impl Default for PersistentSequence { diff --git a/explorer/src/main.rs b/explorer/src/main.rs index 83f51fe329..5792b1eaa4 100644 --- a/explorer/src/main.rs +++ b/explorer/src/main.rs @@ -67,7 +67,7 @@ async fn main() -> Result<(), Error> { async move { let db = bootstrap(sync_stream).await; tracing::debug!("sending ready event"); - if let Err(_) = ready_tx.send(GlobalState::Ready(Indexer::new(db))) { + if ready_tx.send(GlobalState::Ready(Indexer::new(db))).is_err() { todo!("failed to broadcast Ready state after bootstrapping"); } } @@ -170,7 +170,7 @@ async fn rest_service(db: ExplorerDb, settings: Settings) { }, ); - let binding_address = settings.binding_address.clone(); + let binding_address = settings.binding_address; let tls = settings.tls.clone(); let cors = settings.cors.clone(); diff --git a/explorer/src/settings.rs b/explorer/src/settings.rs index 8319138c30..cb57c07133 100644 --- a/explorer/src/settings.rs +++ b/explorer/src/settings.rs @@ -40,19 +40,19 @@ impl Settings { let node = cmd .node .or(file.host) - .unwrap_or("127.0.0.1:8299".parse().unwrap()); + .unwrap_or_else(|| "127.0.0.1:8299".parse().unwrap()); let block0_hash = cmd.block0_hash.parse().unwrap(); let binding_address = cmd .binding_address .or(file.binding_address) - .unwrap_or("0.0.0.0:3030".parse().unwrap()); + .unwrap_or_else(|| "0.0.0.0:3030".parse().unwrap()); let address_bech32_prefix = cmd .address_bech32_prefix - .or(file.address_bech32_prefix.clone()) - .unwrap_or("addr".to_string()); + .or(file.address_bech32_prefix) + .unwrap_or_else(|| "addr".to_string()); let tls = file.tls; let cors = file.cors;