chore(bin/stage): add explicit doc of the use of to-block and hashing stage (#7805)

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Oliver Nordbjerg <onbjerg@users.noreply.github.com>
This commit is contained in:
Delweng
2024-04-23 20:26:57 +08:00
committed by GitHub
parent eabd0220c6
commit 672e4c512c
2 changed files with 9 additions and 4 deletions

View File

@ -236,10 +236,12 @@ impl Command {
/// `reth stage unwind` subcommand
#[derive(Subcommand, Debug, Eq, PartialEq)]
enum Subcommands {
/// Unwinds the database until the given block number (range is inclusive).
/// Unwinds the database from the latest block, until the given block number or hash has been
/// reached, that block is not included.
#[command(name = "to-block")]
ToBlock { target: BlockHashOrNumber },
/// Unwinds the given number of blocks from the database.
/// Unwinds the database from the latest block, until the given number of blocks have been
/// reached.
#[command(name = "num-blocks")]
NumBlocks { amount: u64 },
}
@ -263,6 +265,9 @@ impl Subcommands {
},
Subcommands::NumBlocks { amount } => last.saturating_sub(*amount),
} + 1;
if target > last {
eyre::bail!("Target block number is higher than the latest block number")
}
Ok(target..=last)
}
}