Skip to content

Commit

Permalink
fmt_rs
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Nov 28, 2024
1 parent 583ca3f commit 186dbcf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
6 changes: 4 additions & 2 deletions lib/ain-ocean/src/api/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -131,7 +131,9 @@ pub fn parse_query_height_txid(item: &str) -> Result<(u32, Txid)> {

pub fn parse_price_ticker_sort(item: &str) -> Result<PriceTickerId> {
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..];
Expand Down
2 changes: 1 addition & 1 deletion lib/ain-ocean/src/api/prices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
5 changes: 3 additions & 2 deletions lib/ain-ocean/src/api/stats/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -111,7 +111,8 @@ pub async fn get_count(ctx: &Arc<AppContext>) -> Result<Count> {
.by_id
.list(None, SortOrder::Descending)?
.filter_map(|item| {
item.ok().map(|((_, _, token, currency), _)| (token, currency))
item.ok()
.map(|((_, _, token, currency), _)| (token, currency))
})
.collect::<HashSet<(Token, Currency)>>();

Expand Down
7 changes: 4 additions & 3 deletions lib/ain-ocean/src/indexer/loan_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -92,7 +91,8 @@ pub fn index_active_price(services: &Arc<Services>, 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::<HashSet<(Token, Currency)>>();

Expand Down Expand Up @@ -144,7 +144,8 @@ pub fn invalidate_active_price(services: &Arc<Services>, 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::<HashSet<(Token, Currency)>>();

Expand Down
7 changes: 5 additions & 2 deletions lib/ain-ocean/src/indexer/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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 == &currency,
_ => true
_ => true,
})
.transpose()?;
if let Some((k, _)) = prev_price {
Expand Down

0 comments on commit 186dbcf

Please sign in to comment.