From f3c7f45f69119f9f205cdae6ff6bd1872f9e607b Mon Sep 17 00:00:00 2001 From: canonbrother Date: Fri, 25 Oct 2024 17:16:48 +0800 Subject: [PATCH] fmt_rs --- lib/ain-ocean/src/api/rawtx.rs | 11 ++++------- lib/ain-ocean/src/indexer/poolswap.rs | 17 +++++++++-------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/ain-ocean/src/api/rawtx.rs b/lib/ain-ocean/src/api/rawtx.rs index 7aa89b1f8c..6b2f9017de 100644 --- a/lib/ain-ocean/src/api/rawtx.rs +++ b/lib/ain-ocean/src/api/rawtx.rs @@ -187,13 +187,11 @@ async fn validate_composite_swap_tx(ctx: &Arc, hex: &String) -> Resu Ok(Stack { dftx, .. }) => Some(dftx), }; - let Some(dftx) = dftx else { - return Ok(()) - }; + let Some(dftx) = dftx else { return Ok(()) }; if let DfTx::CompositeSwap(swap) = dftx { let Some(last_pool_id) = swap.pools.iter().last() else { - return Ok(()) + return Ok(()); }; let pool_pair = ctx @@ -205,17 +203,16 @@ async fn validate_composite_swap_tx(ctx: &Arc, hex: &String) -> Resu for (_, info) in pool_pair.0 { if info.id_token_a == to_token_id || info.id_token_b == to_token_id { - return Ok(()) + return Ok(()); } } return Err(Error::BadRequest { msg: "Transaction is not a composite swap".to_string(), - }) + }); }; Ok(()) - } pub fn router(ctx: Arc) -> Router { diff --git a/lib/ain-ocean/src/indexer/poolswap.rs b/lib/ain-ocean/src/indexer/poolswap.rs index fa413f4cb7..e5f70f3e33 100644 --- a/lib/ain-ocean/src/indexer/poolswap.rs +++ b/lib/ain-ocean/src/indexer/poolswap.rs @@ -9,10 +9,14 @@ use snafu::OptionExt; use super::{Context, IndexBlockStart}; use crate::{ - error::{ArithmeticOverflowSnafu, ArithmeticUnderflowSnafu}, indexer::{tx_result, Index, Result}, model::{ + error::{ArithmeticOverflowSnafu, ArithmeticUnderflowSnafu}, + indexer::{tx_result, Index, Result}, + model::{ self, BlockContext, PoolSwapAggregated, PoolSwapAggregatedAggregated, PoolSwapResult, TxResult, - }, storage::{RepositoryOps, SortOrder}, PoolSwapAggregatedService, Services + }, + storage::{RepositoryOps, SortOrder}, + PoolSwapAggregatedService, Services, }; pub const AGGREGATED_INTERVALS: [u32; 2] = [ @@ -151,7 +155,7 @@ fn create_new_bucket( bucket: i64, pool_pair_id: u32, interval: u32, - block: &BlockContext + block: &BlockContext, ) -> Result<()> { let aggregated = PoolSwapAggregated { bucket, @@ -169,12 +173,9 @@ fn create_new_bucket( let pool_swap_aggregated_key = (pool_pair_id, interval, bucket); let pool_swap_aggregated_id = (pool_pair_id, interval, block.hash); - repo - .by_key + repo.by_key .put(&pool_swap_aggregated_key, &pool_swap_aggregated_id)?; - repo - .by_id - .put(&pool_swap_aggregated_id, &aggregated)?; + repo.by_id.put(&pool_swap_aggregated_id, &aggregated)?; Ok(()) }