Commit aa6b9c6a authored by Éloïs's avatar Éloïs
Browse files

feat: add req duration measurement

parent 244e1262
......@@ -23,11 +23,18 @@ pub(crate) fn balance<W: Write>(
ud_unit: bool,
) -> anyhow::Result<()> {
let pubkey_or_script = PubkeyOrScript::from_str(pubkey_or_script)?;
let req_time = Instant::now();
if let Some(AccountBalance {
amount,
ud_amount_opt,
}) = requestor.account_balance(gva_endpoint, &pubkey_or_script, ud_unit)?
{
println!(
"The server responded in {} ms.",
req_time.elapsed().as_millis()
);
if let Some(ud_amount) = ud_amount_opt {
writeln!(
out,
......
......@@ -20,7 +20,13 @@ pub(crate) fn current_ud<W: Write>(
out: &mut W,
requestor: &GvaRequestor,
) -> anyhow::Result<()> {
let req_time = Instant::now();
if let Some(current_ud) = requestor.current_ud(gva_endpoint)? {
println!(
"The server responded in {} ms.",
req_time.elapsed().as_millis()
);
let int_part = current_ud / 100;
let dec_part = current_ud % 100;
writeln!(
......
......@@ -22,12 +22,19 @@ pub(crate) fn idty<W: Write>(
requestor: &GvaRequestor,
) -> anyhow::Result<()> {
let pubkey = PublicKey::from_base58(pubkey)?;
let req_time = Instant::now();
if let Some(Idty {
is_member,
username,
..
}) = requestor.idty_by_pubkey(gva_endpoint, pubkey)?
{
println!(
"The server responded in {} ms.",
req_time.elapsed().as_millis()
);
writeln!(out, "Found identity for pubkey:")?;
writeln!(out, "username: {}", username)?;
writeln!(out, "is_member: {}", is_member)?;
......
......@@ -20,7 +20,12 @@ pub(crate) fn members_count<W: Write>(
out: &mut W,
requestor: &GvaRequestor,
) -> anyhow::Result<()> {
let req_time = Instant::now();
let members_count = requestor.members_count(gva_endpoint)?;
println!(
"The server responded in {} ms.",
req_time.elapsed().as_millis()
);
writeln!(
out,
......
......@@ -46,6 +46,7 @@ use std::{
io::{BufReader, Read, Write},
path::PathBuf,
str::FromStr,
time::Instant,
};
use structopt::StructOpt;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment