Skip to content

Commit

Permalink
v0.0.51
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyMcMillan committed Sep 3, 2024
1 parent d7108a1 commit 4b9de59
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 37 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.0.50"
version = "0.0.51"
edition = "2021"
authors = ["RandyMcMillan <[email protected]>"]
description = "mempool.space api interface."
Expand Down Expand Up @@ -29,15 +29,15 @@ name = "mempool-space"
path = "src/bin/mempool-space.rs"
doc = true

[[bin]]
name = "lightning-search_dashboard"
path = "src/bin/lightning-search_dashboard/src/main.rs"
doc = true

[[bin]]
name = "mempool-space_dashboard"
path = "src/bin/mempool-space_dashboard/src/main.rs"
doc = true
## [[bin]]
## name = "lightning-search_dashboard"
## path = "src/bin/lightning-search_dashboard/src/main.rs"
## doc = true
##
## [[bin]]
## name = "mempool-space_dashboard"
## path = "src/bin/mempool-space_dashboard/src/main.rs"
## doc = true

[package.metadata.wix]
upgrade-guid = "5D3A3DB4-15D1-47AF-BE84-D3A6F541BB8B"
Expand Down
52 changes: 33 additions & 19 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,41 @@ pub const TOR_URL: &str = "http://mempoolhqx4isw62xs7abwphsq7ldayuidyx2v2oethdhh
///
/// pub fn api(option: &str, sub_string: &str) -> String
pub fn api(option: &str, sub_string: &str) -> String {
let mut once: bool = false;
let mut dashboard: std::process::Child;
if option.ends_with("dashboard") {
print!("api:invoke dashboard {:}", option);
let _ = if cfg!(target_os = "windows") {
std::process::Command::new(format!("mempool-space_{}", option))
//.args(["/C", sub_string])
.spawn()
.expect("failed to execute process")
} else {
std::process::Command::new(format!("mempool-space_{}", option))
//.arg(sub_string)
.spawn()
.expect("failed to execute process")
};
//let result = String::from_utf8(output.stdout)
// .map_err(|non_utf8| String::from_utf8_lossy(non_utf8.as_bytes()).into_owned())
// .unwrap();

//return result;
loop {}
loop {
if !once {
info!("api({:}, {:})", option, sub_string);
dashboard = if cfg!(target_os = "windows") {
std::process::Command::new(format!("mempool-space_{}", option))
.args(["/C", "--dashboard"])
.spawn()
.expect("failed to execute process")
} else {
std::process::Command::new(format!("mempool-space_{}", option))
.arg("--dashboard")
.spawn()
.expect("failed to execute process")
};

//std::process::exit(0);
let stdin = dashboard.stdin.take();
let stdout = dashboard.stdout.take();
let stderr = dashboard.stderr.take();
let result = dashboard.wait();
use log::info; //, warn};
info!("{:?}", stdin);
info!("{:?}", stdout);
info!("{:?}", stderr);
info!("{:?}", result);
once = true;
} else {
std::process::exit(0);
}
}
}
if once {
std::process::exit(0);
}

let output = if cfg!(target_os = "windows") {
Expand Down
2 changes: 1 addition & 1 deletion src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ impl Args {
//invoke the dashboard
// DASHBOARD
if matches.opt_present("dashboard") {
api("dashboard", &"");
api("dashboard", "");
};
//mempool api intercepts
// VERSION
Expand Down
4 changes: 3 additions & 1 deletion src/bin/mempool-space_dashboard/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct App {
pub config: Config,
pub tick_rate: f64,
pub frame_rate: f64,
pub dashboard: bool,
pub components: Vec<Box<dyn Component>>,
pub should_quit: bool,
pub should_suspend: bool,
Expand All @@ -29,14 +30,15 @@ pub struct App {
}

impl App {
pub fn new(tick_rate: f64, frame_rate: f64) -> Result<Self> {
pub fn new(tick_rate: f64, frame_rate: f64, dashboard: bool) -> Result<Self> {
let home = Home::new();
let fps = FpsCounter::new();
let config = Config::new()?;
let mode = Mode::Home;
Ok(Self {
tick_rate,
frame_rate,
dashboard,
components: vec![Box::new(home), Box::new(fps)],
should_quit: false,
should_suspend: false,
Expand Down
11 changes: 10 additions & 1 deletion src/bin/mempool-space_dashboard/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::PathBuf;

use clap::Parser;
use clap::{ArgAction, Parser};

use crate::utils::version;

Expand All @@ -24,4 +24,13 @@ pub struct Cli {
default_value_t = 13.0
)]
pub frame_rate: f64,
#[arg(
short,
long,
value_name = "DASHBOARD",
help = "Invoked from mempool-space --dashboard",
default_value_t = false,
action=ArgAction::SetTrue
)]
pub dashboard: bool,
}
4 changes: 2 additions & 2 deletions src/bin/mempool-space_dashboard/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async fn tokio_main() -> Result<()> {
initialize_panic_handler()?;

let args = Cli::parse();
let mut app = App::new(args.tick_rate, args.frame_rate)?;
let mut app = App::new(args.tick_rate, args.frame_rate, args.dashboard)?;
app.run().await?;

Ok(())
Expand All @@ -35,7 +35,7 @@ async fn tokio_main() -> Result<()> {
#[tokio::main]
async fn main() -> Result<()> {
if let Err(e) = tokio_main().await {
eprintln!("{} error: Something went wrong", env!("CARGO_PKG_NAME"));
eprintln!("{} error: tokio_main().await", env!("CARGO_PKG_NAME"));
Err(e)
} else {
Ok(())
Expand Down

0 comments on commit 4b9de59

Please sign in to comment.