From 186dbcf15a9229fdabbdf1a737942b06def25f42 Mon Sep 17 00:00:00 2001 From: canonbrother Date: Thu, 28 Nov 2024 23:07:04 +0800 Subject: [PATCH] fmt_rs --- lib/ain-ocean/src/api/common.rs | 6 ++++-- lib/ain-ocean/src/api/prices.rs | 2 +- lib/ain-ocean/src/api/stats/cache.rs | 5 +++-- lib/ain-ocean/src/indexer/loan_token.rs | 7 ++++--- lib/ain-ocean/src/indexer/oracle.rs | 7 +++++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/ain-ocean/src/api/common.rs b/lib/ain-ocean/src/api/common.rs index 5482bff46d..1b70b257ff 100644 --- a/lib/ain-ocean/src/api/common.rs +++ b/lib/ain-ocean/src/api/common.rs @@ -11,7 +11,7 @@ use super::query::PaginationQuery; use crate::{ error::{ Error::ToArrayError, InvalidAmountSnafu, InvalidFixedIntervalPriceSnafu, - InvalidPriceTickerSortKeySnafu, InvalidPoolPairSymbolSnafu, InvalidTokenCurrencySnafu, + InvalidPoolPairSymbolSnafu, InvalidPriceTickerSortKeySnafu, InvalidTokenCurrencySnafu, }, hex_encoder::as_sha256, model::PriceTickerId, @@ -131,7 +131,9 @@ pub fn parse_query_height_txid(item: &str) -> Result<(u32, Txid)> { pub fn parse_price_ticker_sort(item: &str) -> Result { let mut parts = item.split('-'); - let count_height_token = parts.next().context(InvalidPriceTickerSortKeySnafu { item })?; + let count_height_token = parts + .next() + .context(InvalidPriceTickerSortKeySnafu { item })?; let encoded_count = &count_height_token[..8]; let encoded_height = &count_height_token[8..16]; let token = &count_height_token[16..]; diff --git a/lib/ain-ocean/src/api/prices.rs b/lib/ain-ocean/src/api/prices.rs index df3e79e47c..2986bc042f 100644 --- a/lib/ain-ocean/src/api/prices.rs +++ b/lib/ain-ocean/src/api/prices.rs @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize}; use serde_with::skip_serializing_none; use super::{ - common::{parse_token_currency, parse_price_ticker_sort}, + common::{parse_price_ticker_sort, parse_token_currency}, oracle::OraclePriceFeedResponse, query::PaginationQuery, response::{ApiPagedResponse, Response}, diff --git a/lib/ain-ocean/src/api/stats/cache.rs b/lib/ain-ocean/src/api/stats/cache.rs index cdc60a00b8..9e5d853bbb 100644 --- a/lib/ain-ocean/src/api/stats/cache.rs +++ b/lib/ain-ocean/src/api/stats/cache.rs @@ -27,7 +27,7 @@ use crate::{ stats::get_block_reward_distribution, AppContext, }, - error::{DecimalConversionSnafu, Error, OtherSnafu}, + error::{DecimalConversionSnafu, OtherSnafu}, model::MasternodeStatsData, storage::{RepositoryOps, SortOrder}, Result, @@ -111,7 +111,8 @@ pub async fn get_count(ctx: &Arc) -> Result { .by_id .list(None, SortOrder::Descending)? .filter_map(|item| { - item.ok().map(|((_, _, token, currency), _)| (token, currency)) + item.ok() + .map(|((_, _, token, currency), _)| (token, currency)) }) .collect::>(); diff --git a/lib/ain-ocean/src/indexer/loan_token.rs b/lib/ain-ocean/src/indexer/loan_token.rs index 1182d4c36c..46fc56be97 100644 --- a/lib/ain-ocean/src/indexer/loan_token.rs +++ b/lib/ain-ocean/src/indexer/loan_token.rs @@ -6,7 +6,6 @@ use rust_decimal::{prelude::Zero, Decimal}; use rust_decimal_macros::dec; use crate::{ - error::Error, indexer::{Context, Index, Result}, model::{BlockContext, OraclePriceActive, OraclePriceActiveNext, OraclePriceAggregated}, network::Network, @@ -92,7 +91,8 @@ pub fn index_active_price(services: &Arc, block: &BlockContext) -> Res .by_id .list(None, SortOrder::Descending)? .filter_map(|item| { - item.ok().map(|((_, _, token, currency), _)| (token, currency)) + item.ok() + .map(|((_, _, token, currency), _)| (token, currency)) }) .collect::>(); @@ -144,7 +144,8 @@ pub fn invalidate_active_price(services: &Arc, block: &BlockContext) - .by_id .list(None, SortOrder::Descending)? .filter_map(|item| { - item.ok().map(|((_, _, token, currency), _)| (token, currency)) + item.ok() + .map(|((_, _, token, currency), _)| (token, currency)) }) .collect::>(); diff --git a/lib/ain-ocean/src/indexer/oracle.rs b/lib/ain-ocean/src/indexer/oracle.rs index 589313c842..351af57461 100644 --- a/lib/ain-ocean/src/indexer/oracle.rs +++ b/lib/ain-ocean/src/indexer/oracle.rs @@ -374,7 +374,10 @@ fn index_set_oracle_data( price_aggregated.block.median_time.to_be_bytes(), price_aggregated.block.height.to_be_bytes(), ); - services.oracle_price_aggregated.by_id.put(&id, &price_aggregated)?; + services + .oracle_price_aggregated + .by_id + .put(&id, &price_aggregated)?; let price_repo = &services.price_ticker; let id = ( price_aggregated.aggregated.oracles.total.to_be_bytes(), @@ -387,7 +390,7 @@ fn index_set_oracle_data( .list(Some(id.clone()), SortOrder::Descending)? .find(|item| match item { Ok(((_, _, t, c), _)) => t == &token && c == ¤cy, - _ => true + _ => true, }) .transpose()?; if let Some((k, _)) = prev_price {