pub struct GetBlockStatsCommand { /* private fields */ }
Implementations§
Source§impl GetBlockStatsCommand
impl GetBlockStatsCommand
Sourcepub fn new(target_block: TargetBlockArgument) -> Self
pub fn new(target_block: TargetBlockArgument) -> Self
Examples found in repository?
examples/example.rs (line 61)
58fn get_time_since_last_block(client: &Client) -> Seconds {
59 let block_count = GetBlockCountCommand::new().call(client);
60 let arg = TargetBlockArgument::Height(block_count.unwrap().0);
61 let maybe_block_stats_response = GetBlockStatsCommand::new(arg).call(client);
62 let time_of_last_block = match maybe_block_stats_response {
63 Ok(block_stats_response) => match block_stats_response {
64 GetBlockStatsCommandResponse::AllStats(response) => response.time,
65 GetBlockStatsCommandResponse::SelectiveStats(response) => response.time.unwrap(),
66 },
67 Err(_) => panic!("panic"),
68 };
69 let current_datetime = chrono::offset::Utc::now();
70 let current_timestamp = current_datetime.timestamp();
71 let datetime_of_last_block = Utc.timestamp(time_of_last_block as i64, 0);
72 let difference = current_datetime.signed_duration_since(datetime_of_last_block);
73 Seconds(difference.num_seconds())
74
75 //match SystemTime::now().duration_since(time_of_last_block) {
76 // Ok(seconds) => Ok(seconds.as_secs()),
77 // Err(err) => Err(err),
78 //}
79}
pub fn add_selective_stats( &mut self, stats_argument_choices: Vec<StatsArgumentChoices>, ) -> &Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for GetBlockStatsCommand
impl RefUnwindSafe for GetBlockStatsCommand
impl Send for GetBlockStatsCommand
impl Sync for GetBlockStatsCommand
impl Unpin for GetBlockStatsCommand
impl UnwindSafe for GetBlockStatsCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more