Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
Problem: client-cli history/balance may display outdated information
Browse files Browse the repository at this point in the history
Solution: Added a warning mentioning that the information may be
outdated. One possible improvement is that we can record the time of
last synced block and display that in the warning.
  • Loading branch information
devashishdxt committed Feb 11, 2020
1 parent 6433bb3 commit f62056b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion client-cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cli_table::format::{CellFormat, Color, Justify};
use cli_table::{Cell, Row, Table};
use hex::encode;
use pbr::ProgressBar;
use quest::success;
use quest::{ask, success};
use structopt::StructOpt;

use chain_core::init::coin::Coin;
Expand Down Expand Up @@ -418,6 +418,8 @@ impl Command {

fn get_balance<T: WalletClient>(wallet_client: T, name: &str) -> Result<()> {
let enckey = ask_seckey(None)?;
print_sync_warning();

let balance = wallet_client.balance(name, &enckey)?;

let rows = vec![
Expand Down Expand Up @@ -454,6 +456,8 @@ impl Command {
reversed: bool,
) -> Result<()> {
let enckey = ask_seckey(None)?;
print_sync_warning();

let history = wallet_client.history(name, &enckey, offset, limit, reversed)?;

if !history.is_empty() {
Expand Down Expand Up @@ -572,3 +576,8 @@ impl Command {
Ok(())
}
}

fn print_sync_warning() {
ask("Warning! Information displayed here may be outdated. To get the latest information, do `client-cli sync --name <wallet name>`");
println!();
}

0 comments on commit f62056b

Please sign in to comment.