use avail_rust_client::prelude::*;
#[tokio::main]
pub async fn main() -> Result<(), Error> {
let client = Client::new(TURING_ENDPOINT).await?;
let mut sub = Sub::new(client.clone());
let next_info = sub.next().await?;
let prev_info = sub.prev().await?;
println!("Finalized Next: Block Height: {}, Block Hash: {:?}", next_info.height, next_info.hash);
println!("Finalized Previous: Block Height: {}, Block Hash: {:?}", prev_info.height, prev_info.hash);
let mut sub = Sub::new(client.clone());
sub.use_best_block(true);
let next_info = sub.next().await?;
let prev_info = sub.prev().await?;
println!("Best Next: Block Height: {}, Block Hash: {:?}", next_info.height, next_info.hash);
println!("Best Previous: Block Height: {}, Block Hash: {:?}", prev_info.height, prev_info.hash);
let mut sub = Sub::new(client.clone());
sub.set_block_height(2000000);
let next_info = sub.next().await?;
let prev_info = sub.prev().await?;
println!("Historical Next: Block Height: {}, Block Hash: {:?}", next_info.height, next_info.hash);
println!("Historical Previous: Block Height: {}, Block Hash: {:?}", prev_info.height, prev_info.hash);
Ok(())
}