mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-01-20 19:11:09 +03:00
Add option to limit number of TXs shown (#660)
Co-authored-by: cliik <cliik@example.com>
This commit is contained in:
parent
ef3fadbd24
commit
a3687c69a8
3 changed files with 16 additions and 1 deletions
|
@ -1106,6 +1106,7 @@ where
|
|||
pub struct TxsArgs {
|
||||
pub id: Option<u32>,
|
||||
pub tx_slate_id: Option<Uuid>,
|
||||
pub count: Option<u32>,
|
||||
}
|
||||
|
||||
pub fn txs<L, C, K>(
|
||||
|
@ -1125,11 +1126,15 @@ where
|
|||
let res = api.node_height(m)?;
|
||||
let (validated, txs) = api.retrieve_txs(m, true, args.id, args.tx_slate_id)?;
|
||||
let include_status = !args.id.is_some() && !args.tx_slate_id.is_some();
|
||||
// If view count is specified, restrict the TX list to `txs.len() - count`
|
||||
let first_tx = args
|
||||
.count
|
||||
.map_or(0, |c| txs.len().saturating_sub(c as usize));
|
||||
display::txs(
|
||||
&g_args.account,
|
||||
res.height,
|
||||
validated || updater_running,
|
||||
&txs,
|
||||
&txs[first_tx..],
|
||||
include_status,
|
||||
dark_scheme,
|
||||
)?;
|
||||
|
|
|
@ -333,6 +333,11 @@ subcommands:
|
|||
short: t
|
||||
long: txid
|
||||
takes_value: true
|
||||
- count:
|
||||
help: Maximum number of transactions to show
|
||||
short: c
|
||||
long: count
|
||||
takes_value: true
|
||||
- post:
|
||||
about: Posts a finalized transaction to the chain
|
||||
args:
|
||||
|
|
|
@ -840,9 +840,14 @@ pub fn parse_txs_args(args: &ArgMatches) -> Result<command::TxsArgs, ParseError>
|
|||
let msg = format!("At most one of 'id' (-i) or 'txid' (-t) may be provided.");
|
||||
return Err(ParseError::ArgumentError(msg));
|
||||
}
|
||||
let count = match args.value_of("count") {
|
||||
None => None,
|
||||
Some(c) => Some(parse_u64(c, "count")? as u32),
|
||||
};
|
||||
Ok(command::TxsArgs {
|
||||
id: tx_id,
|
||||
tx_slate_id: tx_slate_id,
|
||||
count: count,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue