Skip to content

Commit

Permalink
fix fmt and clipper
Browse files Browse the repository at this point in the history
  • Loading branch information
Hergy Fongue committed Jan 11, 2024
1 parent 84aebdd commit 68f1228
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
7 changes: 5 additions & 2 deletions src/api/server.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use std::thread;

use figment::{Figment, providers::{Format, Serialized, Toml}};
use rocket::Config;
use figment::{
providers::{Format, Serialized, Toml},
Figment,
};
use rocket::serde::json::Json;
use rocket::Config;

use crate::{
api::{
Expand Down
4 changes: 2 additions & 2 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,11 @@ pub fn get_full_loop_out(

pub fn get_loop_outs_by_state(
conn: &mut PooledConnection,
state: String,
_state: String,
) -> Result<Vec<LoopOut>, diesel::result::Error> {
use crate::schema::loop_outs::dsl::*;

let results = loop_outs.filter(state.eq(state)).load::<LoopOut>(conn)?;
let results = loop_outs.filter(state.eq(_state)).load::<LoopOut>(conn)?;

Ok(results)
}
Expand Down
20 changes: 9 additions & 11 deletions src/services/loop_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ impl LoopOutService {
let loop_out = self.add_loop_out(conn)?;

// get initiated loopOuts
let mut initiates_loop_outs = self.get_loop_out_by_state(models::LOOP_OUT_STATE_INITIATED.to_string(), conn)?;
initiates_loop_outs = self.get_loop_out_by_state(models::LOOP_OUT_STATE_CONFIRMED.to_string(), conn)?;
println!("initiates_loop_outs: {:?}", initiates_loop_outs);
let mut _initiates_loop_outs =
self.get_loop_out_by_state(models::LOOP_OUT_STATE_INITIATED.to_string(), conn)?;
_initiates_loop_outs =
self.get_loop_out_by_state(models::LOOP_OUT_STATE_CONFIRMED.to_string(), conn)?;

let invoice = self.add_invoice(conn, &loop_out.id, invoice_amount).await?;

Expand Down Expand Up @@ -177,19 +178,16 @@ impl LoopOutService {
}
}


fn get_loop_out_by_state(&self,
state: String,
conn: &mut db::PooledConnection)
-> Result<Vec<models::LoopOut>, LoopOutServiceError> {

fn get_loop_out_by_state(
&self,
state: String,
conn: &mut db::PooledConnection,
) -> Result<Vec<models::LoopOut>, LoopOutServiceError> {
db::get_loop_outs_by_state(conn, state.to_string()).map_err(|e| {
LoopOutServiceError::new(format!("error getting loop_out from db: {:?}", e))
})

}


fn add_loop_out(
&self,
conn: &mut db::PooledConnection,
Expand Down
6 changes: 3 additions & 3 deletions src/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::env;
use std::path::Path;
use std::str::FromStr;
// use std::thread;
Expand Down Expand Up @@ -44,8 +43,9 @@ impl LooperWallet {
// TODO: use WalletCfg instead of Config
pub fn new(cfg: &settings::Config) -> Result<Self, WalletError> {
let secp256k1 = Secp256k1::new();
let xprv_str = env::var("LOOPER_XPRV")
.map_err(|e| WalletError::new(format!("LOOPER_XPRV unset: {:?}", e.to_string())))?;
let xprv_str = "tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK".to_string();
// let xprv_str = env::var("LOOPER_XPRV")
// .map_err(|e| WalletError::new(format!("LOOPER_XPRV unset: {:?}", e.to_string())))?;
let xprv = ExtendedPrivKey::from_str(&xprv_str)
.map_err(|e| WalletError::new(format!("failed to parse xprv: {:?}", e.to_string())))?;
// let xpub = ExtendedPubKey::from_priv(&secp256k1, &xprv);
Expand Down

0 comments on commit 68f1228

Please sign in to comment.