nym_cli_commands/validator/block/
block_time.rs

1// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use clap::Parser;
5
6use crate::context::QueryClient;
7use crate::utils::show_error;
8
9#[derive(Debug, Parser)]
10pub struct Args {
11    #[clap(value_parser)]
12    #[clap(help = "The block height")]
13    pub height: u32,
14}
15
16pub async fn query_for_block_time(args: Args, client: &QueryClient) {
17    match client.get_block_timestamp(Some(args.height)).await {
18        Ok(res) => {
19            println!("{}", res.to_rfc3339())
20        }
21        Err(e) => show_error(e),
22    }
23}