Skip to content

Commit 259676b

Browse files
committed
blocks_tip_hash
1 parent f55ce36 commit 259676b

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/args.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ impl Args {
224224
opts.optopt("", "block_status", "block-status api call", "BLOCK_STATUS");
225225

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

228229
//OPTOPT
229230
opts.optopt("c", "config", "sets the configuration file", "CONFIG");
@@ -337,6 +338,10 @@ impl Args {
337338
generic_sys_call("blocks_tip_height", &"extraneous_arg");
338339
std::process::exit(0);
339340
}
341+
if matches.opt_present("blocks_tip_hash") {
342+
generic_sys_call("blocks_tip_hash", &"extraneous_arg");
343+
std::process::exit(0);
344+
}
340345

341346
if matches.opt_present("h")
342347
|| (matches.free.is_empty()
Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
use mempool_space::blocking;
2-
use std::env;
32

43
fn main() {
54
{
6-
let args: Vec<String> = env::args().collect();
7-
let mut address = &String::from("");
8-
if args.len() > 1 {
9-
address = &args[1];
10-
} else {
11-
// silence is golden
12-
std::process::exit(0);
13-
}
14-
let _res = blocking(&format!("/address/{}", &address));
5+
let _res = blocking(&format!("/blocks/tip/hash"));
156
}
167
}

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,14 @@ mod tests {
360360
wait("1");
361361
}
362362
#[test]
363+
fn test_blocks_tip_hash() {
364+
// GET /api/blocks/tip/hash
365+
let binding = format!("blocks/tip/hash").clone();
366+
let block_raw: &str = blocking(&binding).expect("returns current block/tip/hash");
367+
let block_raw = generic_sys_call("blocks_tip_hash", "extraneous_arg");
368+
wait("1");
369+
}
370+
#[test]
363371
fn test_blockheight() {
364372
let blockheight = blockheight::blockheight();
365373
assert_ne!(0 as f64, blockheight.unwrap());

0 commit comments

Comments
 (0)