mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-02-01 08:51:09 +03:00
add ability to specify scan height backwards from tip (#325)
This commit is contained in:
parent
40a0dbdd7f
commit
3571ff8e37
3 changed files with 24 additions and 5 deletions
|
@ -894,6 +894,7 @@ where
|
||||||
pub struct CheckArgs {
|
pub struct CheckArgs {
|
||||||
pub delete_unconfirmed: bool,
|
pub delete_unconfirmed: bool,
|
||||||
pub start_height: Option<u64>,
|
pub start_height: Option<u64>,
|
||||||
|
pub backwards_from_tip: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn scan<L, C, K>(
|
pub fn scan<L, C, K>(
|
||||||
|
@ -907,8 +908,16 @@ where
|
||||||
K: keychain::Keychain + 'static,
|
K: keychain::Keychain + 'static,
|
||||||
{
|
{
|
||||||
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
controller::owner_single_use(None, keychain_mask, Some(owner_api), |api, m| {
|
||||||
warn!("Starting output scan ...",);
|
let tip_height = api.node_height(m)?.height;
|
||||||
let result = api.scan(m, args.start_height, args.delete_unconfirmed);
|
let start_height = match args.backwards_from_tip {
|
||||||
|
Some(b) => tip_height.saturating_sub(b),
|
||||||
|
None => match args.start_height {
|
||||||
|
Some(s) => s,
|
||||||
|
None => 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
warn!("Starting output scan from height {} ...", start_height);
|
||||||
|
let result = api.scan(m, Some(start_height), args.delete_unconfirmed);
|
||||||
match result {
|
match result {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
warn!("Wallet check complete",);
|
warn!("Wallet check complete",);
|
||||||
|
|
|
@ -368,7 +368,11 @@ subcommands:
|
||||||
help: If given, the first block from which to start the scan (default 1)
|
help: If given, the first block from which to start the scan (default 1)
|
||||||
short: h
|
short: h
|
||||||
long: start_height
|
long: start_height
|
||||||
default_value: "1"
|
takes_value: true
|
||||||
|
- backwards_from_tip:
|
||||||
|
help: If given, start scan b blocks back from the tip
|
||||||
|
short: b
|
||||||
|
long: backwards_from_tip,
|
||||||
takes_value: true
|
takes_value: true
|
||||||
- export_proof:
|
- export_proof:
|
||||||
about: Export a payment proof from a completed transaction
|
about: Export a payment proof from a completed transaction
|
||||||
|
|
|
@ -705,9 +705,15 @@ pub fn parse_info_args(args: &ArgMatches) -> Result<command::InfoArgs, ParseErro
|
||||||
pub fn parse_check_args(args: &ArgMatches) -> Result<command::CheckArgs, ParseError> {
|
pub fn parse_check_args(args: &ArgMatches) -> Result<command::CheckArgs, ParseError> {
|
||||||
let delete_unconfirmed = args.is_present("delete_unconfirmed");
|
let delete_unconfirmed = args.is_present("delete_unconfirmed");
|
||||||
let start_height = parse_u64_or_none(args.value_of("start_height"));
|
let start_height = parse_u64_or_none(args.value_of("start_height"));
|
||||||
|
let backwards_from_tip = parse_u64_or_none(args.value_of("backwards_from_tip"));
|
||||||
|
if backwards_from_tip.is_some() && start_height.is_some() {
|
||||||
|
let msg = format!("backwards_from tip and start_height cannot both be present");
|
||||||
|
return Err(ParseError::ArgumentError(msg));
|
||||||
|
}
|
||||||
Ok(command::CheckArgs {
|
Ok(command::CheckArgs {
|
||||||
start_height: start_height,
|
start_height,
|
||||||
delete_unconfirmed: delete_unconfirmed,
|
backwards_from_tip,
|
||||||
|
delete_unconfirmed,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue