Add last_checkpoint argument to zebra-checkpoints (#793)
This commit is contained in:
parent
e74ff18708
commit
917a4fbdbe
|
@ -14,6 +14,11 @@ pub struct Args {
|
|||
#[structopt(default_value = "zcash-cli", short, long)]
|
||||
pub cli: String,
|
||||
|
||||
/// Start looking for checkpoints after this height.
|
||||
/// If there is no last checkpoint, we start looking at the Genesis block (height 0).
|
||||
#[structopt(short, long)]
|
||||
pub last_checkpoint: Option<u32>,
|
||||
|
||||
/// Passthrough args for `zcash-cli`
|
||||
#[structopt(last = true)]
|
||||
pub zcli_args: Vec<String>,
|
||||
|
|
|
@ -89,19 +89,34 @@ fn main() -> Result<()> {
|
|||
cmd.arg("getblockcount");
|
||||
// calculate the maximum height
|
||||
let height_limit: BlockHeight = cmd_output(&mut cmd)?.trim().parse()?;
|
||||
assert!(height_limit <= BlockHeight::MAX);
|
||||
let height_limit = height_limit
|
||||
.0
|
||||
.checked_sub(BLOCK_REORG_LIMIT.0)
|
||||
.map(BlockHeight)
|
||||
.expect("zcashd has some mature blocks: wait for zcashd to sync more blocks");
|
||||
|
||||
let starting_height = args::Args::from_args().last_checkpoint.map(BlockHeight);
|
||||
if starting_height.is_some() {
|
||||
// Since we're about to add 1, height needs to be strictly less than the maximum
|
||||
assert!(starting_height.unwrap() < BlockHeight::MAX);
|
||||
}
|
||||
// Start at the next block after the last checkpoint.
|
||||
// If there is no last checkpoint, start at genesis (height 0).
|
||||
let starting_height = starting_height.map_or(0, |BlockHeight(h)| h + 1);
|
||||
|
||||
assert!(
|
||||
starting_height < height_limit.0,
|
||||
"No mature blocks after the last checkpoint: wait for zcashd to sync more blocks"
|
||||
);
|
||||
|
||||
// set up counters
|
||||
let mut cumulative_bytes: u64 = 0;
|
||||
let mut height_gap: BlockHeight = BlockHeight(0);
|
||||
|
||||
// loop through all blocks
|
||||
for x in 0..height_limit.0 {
|
||||
// unfortunatly we need to create a process for each block
|
||||
for x in starting_height..height_limit.0 {
|
||||
// unfortunately we need to create a process for each block
|
||||
let mut cmd = passthrough_cmd();
|
||||
|
||||
// get block data
|
||||
|
|
Loading…
Reference in New Issue