Skip to content

Commit

Permalink
fmt_rs
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Oct 25, 2024
1 parent 7f98835 commit f3c7f45
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
11 changes: 4 additions & 7 deletions lib/ain-ocean/src/api/rawtx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,11 @@ async fn validate_composite_swap_tx(ctx: &Arc<AppContext>, 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
Expand All @@ -205,17 +203,16 @@ async fn validate_composite_swap_tx(ctx: &Arc<AppContext>, 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<AppContext>) -> Router {
Expand Down
17 changes: 9 additions & 8 deletions lib/ain-ocean/src/indexer/poolswap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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] = [
Expand Down Expand Up @@ -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,
Expand All @@ -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(())
}
Expand Down

0 comments on commit f3c7f45

Please sign in to comment.