From 5c101f993e42374775365015d0fa17604239bfeb Mon Sep 17 00:00:00 2001 From: shufps Date: Mon, 8 Jul 2024 13:03:08 +0200 Subject: [PATCH] cargo fmt --- src/analytics/influx.rs | 10 +++----- src/bin/inx-chronicle/api/explorer/routes.rs | 26 +++++++++++++++----- tests/node_configuration.rs | 12 ++++----- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/analytics/influx.rs b/src/analytics/influx.rs index 165a79b04..e6b1d5a54 100644 --- a/src/analytics/influx.rs +++ b/src/analytics/influx.rs @@ -61,12 +61,10 @@ where M: Measurement, { fn prepare_query(&self) -> Vec { - vec![ - influxdb::Timestamp::from(self.at.milestone_timestamp) - .into_query(M::NAME) - .add_field("milestone_index", self.at.milestone_index) - .add_fields(&self.inner), - ] + vec![influxdb::Timestamp::from(self.at.milestone_timestamp) + .into_query(M::NAME) + .add_field("milestone_index", self.at.milestone_index) + .add_fields(&self.inner)] } } diff --git a/src/bin/inx-chronicle/api/explorer/routes.rs b/src/bin/inx-chronicle/api/explorer/routes.rs index 3568131d8..3290c20d5 100644 --- a/src/bin/inx-chronicle/api/explorer/routes.rs +++ b/src/bin/inx-chronicle/api/explorer/routes.rs @@ -26,9 +26,10 @@ use iota_sdk::types::block::address::{Hrp, ToBech32Ext}; use super::{ extractors::{ - BlocksByMilestoneCursor, BlocksByMilestoneIdPagination, BlocksByMilestoneIndexPagination, TokenDistributionQuery, + BlocksByMilestoneCursor, BlocksByMilestoneIdPagination, BlocksByMilestoneIndexPagination, LedgerUpdatesByAddressCursor, LedgerUpdatesByAddressPagination, LedgerUpdatesByMilestoneCursor, LedgerUpdatesByMilestonePagination, MilestonesCursor, MilestonesPagination, RichestAddressesQuery, + TokenDistributionQuery, }, responses::{ AddressStatDto, BalanceResponse, BlockChildrenResponse, BlockPayloadTypeDto, BlocksByMilestoneResponse, @@ -343,7 +344,10 @@ fn get_seconds_until_midnight() -> u64 { fn get_days_since_epoch() -> u64 { let now = SystemTime::now(); - let secs_since_epoch = now.duration_since(SystemTime::UNIX_EPOCH).expect("Time went backwards").as_secs(); + let secs_since_epoch = now + .duration_since(SystemTime::UNIX_EPOCH) + .expect("Time went backwards") + .as_secs(); secs_since_epoch / 86400 } @@ -360,7 +364,11 @@ fn get_cache_bool(cache: Option) -> bool { async fn richest_addresses_ledger_analytics( database: Extension, - RichestAddressesQuery { top, ledger_index , cached}: RichestAddressesQuery, + RichestAddressesQuery { + top, + ledger_index, + cached, + }: RichestAddressesQuery, ) -> ApiResult { let ledger_index = resolve_ledger_index(&database, ledger_index).await?; let mut cache = RICHEST_ADDRESSES_CACHE.write().await; @@ -407,7 +415,10 @@ async fn richest_addresses_ledger_analytics( if cached { // Store the response in the cache - *cache = Some(RichestCacheData { last_updated: days_since_epoch, data: response.clone() }); + *cache = Some(RichestCacheData { + last_updated: days_since_epoch, + data: response.clone(), + }); let refresh_elapsed = refresh_start.elapsed().unwrap(); info!("refreshing richest-addresses cache done. Took {:?}", refresh_elapsed); @@ -419,7 +430,7 @@ async fn richest_addresses_ledger_analytics( async fn token_distribution_ledger_analytics( database: Extension, - TokenDistributionQuery { ledger_index, cached}: TokenDistributionQuery, + TokenDistributionQuery { ledger_index, cached }: TokenDistributionQuery, ) -> ApiResult { let ledger_index = resolve_ledger_index(&database, ledger_index).await?; let mut cache = TOKEN_DISTRIBUTION_CACHE.write().await; @@ -449,7 +460,10 @@ async fn token_distribution_ledger_analytics( if cached { // Store the response in the cache - *cache = Some(TokenCacheData { last_updated: days_since_epoch, data: response.clone() }); + *cache = Some(TokenCacheData { + last_updated: days_since_epoch, + data: response.clone(), + }); let refresh_elapsed = refresh_start.elapsed().unwrap(); info!("refreshing token-distribution cache done. Took {:?}", refresh_elapsed); diff --git a/tests/node_configuration.rs b/tests/node_configuration.rs index e43e24eab..64cbae483 100644 --- a/tests/node_configuration.rs +++ b/tests/node_configuration.rs @@ -19,13 +19,11 @@ mod test_rand { let node_configuration = setup_collection::(&db).await.unwrap(); // empty collection - assert!( - node_configuration - .get_latest_node_configuration() - .await - .unwrap() - .is_none() - ); + assert!(node_configuration + .get_latest_node_configuration() + .await + .unwrap() + .is_none()); let mut config = NodeConfiguration { milestone_public_key_count: 3,