|
|
@ -95,9 +95,9 @@ pub fn get_coinsupply(uri: http::Uri, no_cert: bool) -> Result<Coinsupply, Strin |
|
|
|
// tokio::runtime::current_thread::Runtime::new().unwrap().block_on(runner)
|
|
|
|
} |
|
|
|
|
|
|
|
async fn get_block_range<F : 'static + std::marker::Send>(uri: &http::Uri, start_height: u64, end_height: u64, no_cert: bool, mut c: F)
|
|
|
|
async fn get_block_range<F : 'static + std::marker::Send>(uri: &http::Uri, start_height: u64, end_height: u64, no_cert: bool, c: F)
|
|
|
|
-> Result<(), Box<dyn std::error::Error>>
|
|
|
|
where F : FnMut(&[u8], u64) { |
|
|
|
where F : Fn(&[u8], u64) { |
|
|
|
let mut client = get_client(uri, no_cert).await?; |
|
|
|
|
|
|
|
let bs = BlockId{ height: start_height, hash: vec!()}; |
|
|
@ -118,19 +118,28 @@ where F : FnMut(&[u8], u64) { |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
|
|
|
|
pub fn fetch_blocks<F : 'static + std::marker::Send>(uri: &http::Uri, start_height: u64, end_height: u64, no_cert: bool, c: F) |
|
|
|
where F : FnMut(&[u8], u64) { |
|
|
|
pub fn fetch_blocks<F : 'static + std::marker::Send>(uri: &http::Uri, start_height: u64, end_height: u64, no_cert: bool, c: F) -> Result<(), String> |
|
|
|
where F : Fn(&[u8], u64) { |
|
|
|
|
|
|
|
let mut rt = match tokio::runtime::Runtime::new() { |
|
|
|
Ok(r) => r, |
|
|
|
Err(e) => { |
|
|
|
error!("Error fetching blocks {}", e.to_string()); |
|
|
|
let es = format!("Error creating runtime {:?}", e); |
|
|
|
error!("{}", es); |
|
|
|
eprintln!("{}", e); |
|
|
|
return; |
|
|
|
return Err(es); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
rt.block_on(get_block_range(uri, start_height, end_height, no_cert, c)).unwrap(); |
|
|
|
match rt.block_on(get_block_range(uri, start_height, end_height, no_cert, c)) { |
|
|
|
Ok(o) => Ok(o), |
|
|
|
Err(e) => { |
|
|
|
let e = format!("Error fetching blocks {:?}", e); |
|
|
|
error!("{}", e); |
|
|
|
eprintln!("{}", e); |
|
|
|
Err(e) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -157,19 +166,28 @@ async fn get_address_txids<F : 'static + std::marker::Send>(uri: &http::Uri, add |
|
|
|
|
|
|
|
|
|
|
|
pub fn fetch_transparent_txids<F : 'static + std::marker::Send>(uri: &http::Uri, address: String,
|
|
|
|
start_height: u64, end_height: u64, no_cert: bool, c: F) |
|
|
|
start_height: u64, end_height: u64, no_cert: bool, c: F) -> Result<(), String> |
|
|
|
where F : Fn(&[u8], u64) { |
|
|
|
|
|
|
|
let mut rt = match tokio::runtime::Runtime::new() { |
|
|
|
Ok(r) => r, |
|
|
|
Err(e) => { |
|
|
|
error!("Error creating runtime {}", e.to_string()); |
|
|
|
let e = format!("Error creating runtime {:?}", e); |
|
|
|
error!("{}", e); |
|
|
|
eprintln!("{}", e); |
|
|
|
return; |
|
|
|
return Err(e); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
rt.block_on(get_address_txids(uri, address, start_height, end_height, no_cert, c)).unwrap(); |
|
|
|
match rt.block_on(get_address_txids(uri, address.clone(), start_height, end_height, no_cert, c)) { |
|
|
|
Ok(o) => Ok(o), |
|
|
|
Err(e) => { |
|
|
|
let e = format!("Error with get_address_txids runtime {:?}", e); |
|
|
|
error!("{}", e); |
|
|
|
eprintln!("{}", e); |
|
|
|
Err(e) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|