fix taker offer fetching, change log level for crate dependencies

This commit is contained in:
f321x
2024-07-09 09:00:36 +00:00
parent 0c8a27415a
commit 320d46e0f3
3 changed files with 8 additions and 6 deletions

View File

@ -197,7 +197,7 @@ impl CoordinatorDB {
bond_address: fetched_values.5, bond_address: fetched_values.5,
bond_amount_sat: fetched_values.6 as u64, bond_amount_sat: fetched_values.6 as u64,
}; };
info!( debug!(
"Deleted offer from maker_requests table. Fetched offer: {:#?}", "Deleted offer from maker_requests table. Fetched offer: {:#?}",
awaiting_bond_offer awaiting_bond_offer
); );
@ -214,7 +214,7 @@ impl CoordinatorDB {
.fetch_and_delete_offer_from_bond_table(&data.robohash_hex) .fetch_and_delete_offer_from_bond_table(&data.robohash_hex)
.await?; .await?;
info!( debug!(
"DATABASE: Moving maker offer to active trades table. Bond data: {:#?}", "DATABASE: Moving maker offer to active trades table. Bond data: {:#?}",
data data
); );
@ -238,6 +238,7 @@ impl CoordinatorDB {
.bind(taker_bond_address) .bind(taker_bond_address)
.execute(&*self.db_pool) .execute(&*self.db_pool)
.await?; .await?;
debug!("\nDATABASE: moved offer to active trades\n"); debug!("\nDATABASE: moved offer to active trades\n");
Ok(remaining_offer_information.offer_duration_ts) Ok(remaining_offer_information.offer_duration_ts)
} }
@ -246,7 +247,7 @@ impl CoordinatorDB {
&self, &self,
requested_offer: &OffersRequest, requested_offer: &OffersRequest,
) -> Result<Option<Vec<PublicOffer>>> { ) -> Result<Option<Vec<PublicOffer>>> {
info!( debug!(
"Fetching suitable offers from db. Specification: {:#?}", "Fetching suitable offers from db. Specification: {:#?}",
requested_offer requested_offer
); );
@ -271,7 +272,7 @@ impl CoordinatorDB {
) )
.collect(); .collect();
if available_offers.is_empty() { if available_offers.is_empty() {
info!("No available offers in db..."); debug!("No available offers in db...");
return Ok(None); return Ok(None);
} }
Ok(Some(available_offers)) Ok(Some(available_offers))

View File

@ -24,10 +24,11 @@ pub struct Coordinator {
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {
env_logger::builder() env_logger::builder()
.filter_module("coordinator", log::LevelFilter::Debug)
.filter_level(log::LevelFilter::Info) .filter_level(log::LevelFilter::Info)
.init(); .init();
dotenv().ok(); dotenv().ok();
debug!("Starting coordinator");
// Initialize the database pool // Initialize the database pool
let coordinator = Arc::new(Coordinator { let coordinator = Arc::new(Coordinator {
coordinator_db: Arc::new(CoordinatorDB::init().await?), coordinator_db: Arc::new(CoordinatorDB::init().await?),

View File

@ -7,7 +7,7 @@ impl PublicOffers {
pub fn fetch(taker_config: &TraderSettings) -> Result<PublicOffers> { pub fn fetch(taker_config: &TraderSettings) -> Result<PublicOffers> {
let amount = taker_config.trade_type.value(); let amount = taker_config.trade_type.value();
let request = OffersRequest { let request = OffersRequest {
buy_offers: taker_config.trade_type.is_buy_order(), buy_offers: !taker_config.trade_type.is_buy_order(),
amount_min_sat: (amount as f64 * 0.9).round() as u64, // range can be made variable in production amount_min_sat: (amount as f64 * 0.9).round() as u64, // range can be made variable in production
amount_max_sat: (amount as f64 * 1.1).round() as u64, amount_max_sat: (amount as f64 * 1.1).round() as u64,
}; };