Skip to content

Commit

Permalink
src:apply cargo fmt and sort
Browse files Browse the repository at this point in the history
  • Loading branch information
RandyMcMillan committed Jul 30, 2024
1 parent 3420594 commit 01b8847
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 25 deletions.
3 changes: 2 additions & 1 deletion src/bin/block-header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use reqwest::Url;

// use ureq::get;

const URL: &str = "https://mempool.space/api/block/0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2/header";
const URL: &str =
"https://mempool.space/api/block/0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2/header";

fn main() {
let n = 1;
Expand Down
9 changes: 5 additions & 4 deletions src/bin/block-raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ use reqwest::Url;

// use ureq::get;

//REF:
// REF:
// Usage:
// curl -sSL "https://mempool.space/api/block/0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2/raw" | hexdump
const URL: &str = "https://mempool.space/api/block/0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2/raw";
const URL: &str =
"https://mempool.space/api/block/0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2/raw";

fn main() {
let n = 1;
Expand All @@ -34,7 +35,7 @@ fn blocking(n: usize) -> usize {
let mut body = ureq::get(URL).call().expect("REASON").into_reader();
let mut buf = Vec::new();
body.read_to_end(&mut buf).unwrap();
//body.read_to_end(&mut buf).unwrap();
// body.read_to_end(&mut buf).unwrap();
// print block count from mempool.space or panic
// let text = match std::str::from_utf8(&buf) {
// Ok(s) => s,
Expand All @@ -50,7 +51,7 @@ fn blocking(n: usize) -> usize {
.sum()
}

//async fn non_blocking(n: usize) -> usize {
// async fn non_blocking(n: usize) -> usize {
// // let tasks = (0..n)
// // .into_iter()
// // .map(|_| {
Expand Down
3 changes: 2 additions & 1 deletion src/bin/block-status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use reqwest::Url;

// use ureq::get;

const URL: &str = "https://mempool.space/api/block/0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2/status";
const URL: &str =
"https://mempool.space/api/block/0000000000000000000065bda8f8a88f2e1e00d9a6887a43d640e52a4c7660f2/status";

fn main() {
let n = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/blocks-height.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use reqwest::Url;

// use ureq::get;

//const URL: &str = "https://mempool.space/api/blocks";
//const URL: &str = "https://mempool.space/api/blocks/tip";
// const URL: &str = "https://mempool.space/api/blocks";
// const URL: &str = "https://mempool.space/api/blocks/tip";
const URL: &str = "https://mempool.space/api/blocks/tip/height";

fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/bin/blocks-tip-hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use reqwest::Url;

// use ureq::get;

//const URL: &str = "https://mempool.space/api/blocks";
// const URL: &str = "https://mempool.space/api/blocks";
const URL: &str = "https://mempool.space/api/blocks/tip/hash";
//const URL: &str = "https://mempool.space/api/blocks/tip/height";
// const URL: &str = "https://mempool.space/api/blocks/tip/height";

fn main() {
let n = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/blocks-tip-height.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use reqwest::Url;

// use ureq::get;

//const URL: &str = "https://mempool.space/api/blocks";
// const URL: &str = "https://mempool.space/api/blocks";
const URL: &str = "https://mempool.space/api/blocks/tip/height";
//const URL: &str = "https://mempool.space/api/blocks/tip/height";
// const URL: &str = "https://mempool.space/api/blocks/tip/height";

fn main() {
let n = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/blocks-tip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use reqwest::Url;

// use ureq::get;

//const URL: &str = "https://mempool.space/api/blocks";
// const URL: &str = "https://mempool.space/api/blocks";
const URL: &str = "https://mempool.space/api/blocks/tip";
//const URL: &str = "https://mempool.space/api/blocks/tip/height";
// const URL: &str = "https://mempool.space/api/blocks/tip/height";

fn main() {
let n = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/bin/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use reqwest::Url;
// use ureq::get;

const URL: &str = "https://mempool.space/api/blocks";
//const URL: &str = "https://mempool.space/api/blocks/tip";
//const URL: &str = "https://mempool.space/api/blocks/tip/height";
// const URL: &str = "https://mempool.space/api/blocks/tip";
// const URL: &str = "https://mempool.space/api/blocks/tip/height";

fn main() {
let n = 1;
Expand Down
8 changes: 4 additions & 4 deletions src/bin/difficulty-adjustment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ use reqwest::Url;

const URL: &str = "https://mempool.space/api/v1/difficulty-adjustment";

//const URL: &str = "https://mempool.space/api/blocks/tip";
//const URL: &str = "https://mempool.space/api/blocks/tip/height";
// const URL: &str = "https://mempool.space/api/blocks/tip";
// const URL: &str = "https://mempool.space/api/blocks/tip/height";

fn main() {
let n = 1;
{
let start = Instant::now();
let res = blocking(n);
//println!("blocking {:?} {} bytes", start.elapsed(), res);
// println!("blocking {:?} {} bytes", start.elapsed(), res);
}
{
let start = Instant::now();
let rt = tokio::runtime::Runtime::new().unwrap();
let res = rt.block_on(non_blocking(n));
//println!("async {:?} {} bytes", start.elapsed(), res);
// println!("async {:?} {} bytes", start.elapsed(), res);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/bin/mining-blocks-timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use reqwest::Url;
// use ureq::get;

const URL: &str = "https://mempool.space/api/v1/mining/blocks/timestamp/1672531200";
//const URL: &str = "https://mempool.space/api/blocks/tip";
//const URL: &str = "https://mempool.space/api/blocks/tip/height";
// const URL: &str = "https://mempool.space/api/blocks/tip";
// const URL: &str = "https://mempool.space/api/blocks/tip/height";

fn main() {
let n = 1;
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
//! Additionally this crate contains asynchronous utilities to execute these checks regularly
//! within a given time interval.

use std::time::SystemTime;
use std::io::Read;
use reqwest::Url;
use std::io::Read;
use std::time::SystemTime;

use crate::blockheight::blockheight;

Expand Down

0 comments on commit 01b8847

Please sign in to comment.