Skip to content

Commit

Permalink
blocks_tip_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyMcMillan committed Aug 14, 2024
1 parent f55ce36 commit 259676b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ impl Args {
opts.optopt("", "block_status", "block-status api call", "BLOCK_STATUS");

opts.optflag("", "blocks_tip_height", "GET /api/blocks/tip/height api call");
opts.optflag("", "blocks_tip_hash", "GET /api/blocks/tip/hash api call");

//OPTOPT
opts.optopt("c", "config", "sets the configuration file", "CONFIG");
Expand Down Expand Up @@ -337,6 +338,10 @@ impl Args {
generic_sys_call("blocks_tip_height", &"extraneous_arg");
std::process::exit(0);
}
if matches.opt_present("blocks_tip_hash") {
generic_sys_call("blocks_tip_hash", &"extraneous_arg");
std::process::exit(0);
}

if matches.opt_present("h")
|| (matches.free.is_empty()
Expand Down
11 changes: 1 addition & 10 deletions src/bin/mempool-space_blocks_tip_hash.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
use mempool_space::blocking;
use std::env;

fn main() {
{
let args: Vec<String> = env::args().collect();
let mut address = &String::from("");
if args.len() > 1 {
address = &args[1];
} else {
// silence is golden
std::process::exit(0);
}
let _res = blocking(&format!("/address/{}", &address));
let _res = blocking(&format!("/blocks/tip/hash"));
}
}
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,14 @@ mod tests {
wait("1");
}
#[test]
fn test_blocks_tip_hash() {
// GET /api/blocks/tip/hash
let binding = format!("blocks/tip/hash").clone();
let block_raw: &str = blocking(&binding).expect("returns current block/tip/hash");
let block_raw = generic_sys_call("blocks_tip_hash", "extraneous_arg");
wait("1");
}
#[test]
fn test_blockheight() {
let blockheight = blockheight::blockheight();
assert_ne!(0 as f64, blockheight.unwrap());
Expand Down

0 comments on commit 259676b

Please sign in to comment.