Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
shufps committed Jul 8, 2024
1 parent ee13b46 commit 5c101f9
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
10 changes: 4 additions & 6 deletions src/analytics/influx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ where
M: Measurement,
{
fn prepare_query(&self) -> Vec<WriteQuery> {
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)]
}
}

Expand Down
26 changes: 20 additions & 6 deletions src/bin/inx-chronicle/api/explorer/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}

Expand All @@ -360,7 +364,11 @@ fn get_cache_bool(cache: Option<bool>) -> bool {

async fn richest_addresses_ledger_analytics(
database: Extension<MongoDb>,
RichestAddressesQuery { top, ledger_index , cached}: RichestAddressesQuery,
RichestAddressesQuery {
top,
ledger_index,
cached,
}: RichestAddressesQuery,
) -> ApiResult<RichestAddressesResponse> {
let ledger_index = resolve_ledger_index(&database, ledger_index).await?;
let mut cache = RICHEST_ADDRESSES_CACHE.write().await;
Expand Down Expand Up @@ -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);
Expand All @@ -419,7 +430,7 @@ async fn richest_addresses_ledger_analytics(

async fn token_distribution_ledger_analytics(
database: Extension<MongoDb>,
TokenDistributionQuery { ledger_index, cached}: TokenDistributionQuery,
TokenDistributionQuery { ledger_index, cached }: TokenDistributionQuery,
) -> ApiResult<TokenDistributionResponse> {
let ledger_index = resolve_ledger_index(&database, ledger_index).await?;
let mut cache = TOKEN_DISTRIBUTION_CACHE.write().await;
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 5 additions & 7 deletions tests/node_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ mod test_rand {
let node_configuration = setup_collection::<ConfigurationUpdateCollection>(&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,
Expand Down

0 comments on commit 5c101f9

Please sign in to comment.