diff --git a/bin/reflux/src/main.rs b/bin/reflux/src/main.rs index d3d0b42..a5f38a1 100644 --- a/bin/reflux/src/main.rs +++ b/bin/reflux/src/main.rs @@ -6,9 +6,7 @@ use std::time::Duration; use axum::http::Method; use clap::Parser; use dotenv::dotenv; -use futures_util::future::join_all; use log::{debug, error, info}; -use tokio::join; use tokio::sync::Mutex; use tower_http::cors::{Any, CorsLayer}; @@ -52,7 +50,7 @@ async fn main() { } simple_logger::SimpleLogger::new().env().init().unwrap(); - let mut args = Args::parse(); + let args = Args::parse(); debug!("Args: {:?}", args); if args.indexer && args.solver { @@ -177,6 +175,9 @@ async fn run_solver(config: Arc) { }) .collect(); + // run the cache refresh once at the start + routing_engine.refresh_cache().await; + // API service controller let chain_supported: Vec<(u32, String)> = config.chains.iter().map(|(id, chain)| (*id, chain.name.clone())).collect(); diff --git a/crates/routing-engine/src/routing_engine.rs b/crates/routing-engine/src/routing_engine.rs index c2c8d6a..8f4fa00 100644 --- a/crates/routing-engine/src/routing_engine.rs +++ b/crates/routing-engine/src/routing_engine.rs @@ -8,14 +8,13 @@ use thiserror::Error; use tokio::sync::RwLock; use account_aggregation::{service::AccountAggregationService, types::TokenWithBalance}; -use config::{ChainConfig, Config, config::BucketConfig, SolverConfig, TokenConfig}; +use config::{config::BucketConfig, ChainConfig, Config, SolverConfig, TokenConfig}; use storage::{KeyValueStore, RedisClient, RedisClientError}; use crate::{ - BridgeResult, - BridgeResultVecWrapper, estimator::{Estimator, LinearRegressionEstimator}, Route, + estimator::{Estimator, LinearRegressionEstimator}, + BridgeResult, BridgeResultVecWrapper, Route, }; -use crate::token_price::utils::get_token_price; /// (from_chain, to_chain, from_token, to_token) #[derive(Debug)] @@ -345,12 +344,12 @@ mod tests { use config::{BucketConfig, ChainConfig, SolverConfig, TokenConfig, TokenConfigByChainConfigs}; use storage::mongodb_client::MongoDBClient; + use crate::estimator::Estimator; + use crate::routing_engine::PathQuery; use crate::{ estimator::{DataPoint, LinearRegressionEstimator}, routing_engine::{RoutingEngine, RoutingEngineError}, }; - use crate::estimator::Estimator; - use crate::routing_engine::PathQuery; #[tokio::test] async fn test_get_cached_data() -> Result<(), RoutingEngineError> {