Init db after tracing

This commit is contained in:
rishflab 2021-10-05 22:41:38 +11:00
parent f91d8ab45c
commit 8fb15ba7aa

View File

@ -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")?;