From 8fb15ba7aa3962eff8da749c35555728a4b3dbbc Mon Sep 17 00:00:00 2001 From: rishflab Date: Tue, 5 Oct 2021 22:41:38 +1100 Subject: [PATCH] Init db after tracing --- swap/src/bin/swap.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/swap/src/bin/swap.rs b/swap/src/bin/swap.rs index 6dc1e581..a8d7b3f9 100644 --- a/swap/src/bin/swap.rs +++ b/swap/src/bin/swap.rs @@ -55,8 +55,6 @@ async fn main() -> Result<()> { } }; - let db = open_db(data_dir.join("database"), data_dir.join("sqlite"), sled).await?; - match cmd { Command::BuyXmr { seller, @@ -70,6 +68,7 @@ async fn main() -> Result<()> { let swap_id = Uuid::new_v4(); cli::tracing::init(debug, json, data_dir.join("logs"), Some(swap_id))?; + let db = open_db(data_dir.join("database"), data_dir.join("sqlite"), sled).await?; let seed = Seed::from_file_or_generate(data_dir.as_path()) .context("Failed to read in seed file")?; @@ -84,7 +83,6 @@ async fn main() -> Result<()> { let (monero_wallet, _process) = init_monero_wallet(data_dir, monero_daemon_address, env_config).await?; let bitcoin_wallet = Arc::new(bitcoin_wallet); - let seller_peer_id = seller .extract_peer_id() .context("Seller address must contain peer ID")?; @@ -141,6 +139,7 @@ async fn main() -> Result<()> { } } Command::History => { + let db = open_db(data_dir.join("database"), data_dir.join("sqlite"), sled).await?; let mut table = Table::new(); table.set_header(vec!["SWAP ID", "STATE"]); @@ -245,6 +244,7 @@ async fn main() -> Result<()> { tor_socks5_port, } => { cli::tracing::init(debug, json, data_dir.join("logs"), Some(swap_id))?; + let db = open_db(data_dir.join("database"), data_dir.join("sqlite"), sled).await?; let seed = Seed::from_file_or_generate(data_dir.as_path()) .context("Failed to read in seed file")?; @@ -306,6 +306,7 @@ async fn main() -> Result<()> { bitcoin_target_block, } => { cli::tracing::init(debug, json, data_dir.join("logs"), Some(swap_id))?; + let db = open_db(data_dir.join("database"), data_dir.join("sqlite"), sled).await?; let seed = Seed::from_file_or_generate(data_dir.as_path()) .context("Failed to read in seed file")?; @@ -327,6 +328,7 @@ async fn main() -> Result<()> { bitcoin_target_block, } => { cli::tracing::init(debug, json, data_dir.join("logs"), Some(swap_id))?; + let db = open_db(data_dir.join("database"), data_dir.join("sqlite"), sled).await?; let seed = Seed::from_file_or_generate(data_dir.as_path()) .context("Failed to read in seed file")?;