mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-08-13 08:45:53 -04:00
Re-introduce history command
This commit is contained in:
parent
0f1a77fa21
commit
09773dd15b
3 changed files with 22 additions and 4 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
# Created by https://www.toptal.com/developers/gitignore/api/rust,clion+all,emacs
|
# Created by https://www.toptal.com/developers/gitignore/api/rust,clion+all,emacs
|
||||||
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,clion+all,emacs
|
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,clion+all,emacs
|
||||||
|
|
||||||
|
@ -154,4 +153,7 @@ Cargo.lock
|
||||||
# These are backup files generated by rustfmt
|
# These are backup files generated by rustfmt
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|
||||||
|
# sled DB directory generated during local development
|
||||||
|
.swap-db/
|
||||||
|
|
||||||
# End of https://www.toptal.com/developers/gitignore/api/rust,clion+all,emacs
|
# End of https://www.toptal.com/developers/gitignore/api/rust,clion+all,emacs
|
||||||
|
|
|
@ -33,4 +33,5 @@ pub enum Options {
|
||||||
#[structopt(long = "tor")]
|
#[structopt(long = "tor")]
|
||||||
tor: bool,
|
tor: bool,
|
||||||
},
|
},
|
||||||
|
History,
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use anyhow::Result;
|
||||||
use futures::{channel::mpsc, StreamExt};
|
use futures::{channel::mpsc, StreamExt};
|
||||||
use libp2p::Multiaddr;
|
use libp2p::Multiaddr;
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
|
use prettytable::{row, Table};
|
||||||
use std::{io, io::Write, process, sync::Arc};
|
use std::{io, io::Write, process, sync::Arc};
|
||||||
use structopt::StructOpt;
|
use structopt::StructOpt;
|
||||||
use swap::{
|
use swap::{
|
||||||
|
@ -27,9 +28,11 @@ use swap::{
|
||||||
network::transport::{build, build_tor, SwapTransport},
|
network::transport::{build, build_tor, SwapTransport},
|
||||||
Cmd, Rsp, SwapAmounts,
|
Cmd, Rsp, SwapAmounts,
|
||||||
};
|
};
|
||||||
use tempfile::tempdir;
|
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate prettytable;
|
||||||
|
|
||||||
mod cli;
|
mod cli;
|
||||||
mod trace;
|
mod trace;
|
||||||
|
|
||||||
|
@ -44,8 +47,8 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
trace::init_tracing(LevelFilter::Debug)?;
|
trace::init_tracing(LevelFilter::Debug)?;
|
||||||
|
|
||||||
let db_dir = tempdir()?;
|
// This currently creates the directory if it's not there in the first place
|
||||||
let db = Database::open(db_dir.path()).unwrap();
|
let db = Database::open(std::path::Path::new("./.swap-db/")).unwrap();
|
||||||
|
|
||||||
match opt {
|
match opt {
|
||||||
Options::Alice {
|
Options::Alice {
|
||||||
|
@ -130,6 +133,18 @@ async fn main() -> Result<()> {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
Options::History => {
|
||||||
|
let mut table = Table::new();
|
||||||
|
|
||||||
|
table.add_row(row!["SWAP ID", "STATE"]);
|
||||||
|
|
||||||
|
for (swap_id, state) in db.all()? {
|
||||||
|
table.add_row(row![swap_id, state]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print the table to stdout
|
||||||
|
table.printstd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue