Skip to content

Commit

Permalink
rename mode to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
oxarbitrage committed Jan 19, 2023
1 parent 670d325 commit a206792
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
20 changes: 10 additions & 10 deletions zebra-utils/src/bin/zebra-checkpoints/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ use thiserror::Error;

use std::str::FromStr;

/// Backend
/// The backend type the zebra-checkpoints utility will use to get data from.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Mode {
Zebra,
Zcash,
pub enum Backend {
Zebrad,
Zcashd,
}

impl FromStr for Mode {
impl FromStr for Backend {
type Err = InvalidModeError;

fn from_str(string: &str) -> Result<Self, Self::Err> {
match string.to_lowercase().as_str() {
"zebra" => Ok(Mode::Zebra),
"zcash" => Ok(Mode::Zcash),
"zebrad" => Ok(Backend::Zebrad),
"zcashd" => Ok(Backend::Zcashd),
_ => Err(InvalidModeError(string.to_owned())),
}
}
Expand All @@ -33,9 +33,9 @@ pub struct InvalidModeError(String);
/// zebra-checkpoints arguments
#[derive(Clone, Debug, Eq, PartialEq, StructOpt)]
pub struct Args {
/// Mode
#[structopt(default_value = "zebra", short, long)]
pub mode: Mode,
/// Backend type
#[structopt(default_value = "zebrad", short, long)]
pub backend: Backend,

/// Path to zcash-cli command
#[structopt(default_value = "zcash-cli", short, long)]
Expand Down
10 changes: 5 additions & 5 deletions zebra-utils/src/bin/zebra-checkpoints/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ fn main() -> Result<()> {
// unfortunately we need to create a process for each block
let mut cmd = passthrough_cmd();

let (hash, height, size) = match args::Args::from_args().mode {
args::Mode::Zcash => {
// get block data
let (hash, height, size) = match args::Args::from_args().backend {
args::Backend::Zcashd => {
// get block data from zcashd using verbose=1
cmd.args(["getblock", &x.to_string(), "1"]);
let output = cmd_output(&mut cmd)?;

Expand All @@ -129,8 +129,8 @@ fn main() -> Result<()> {

(hash, height, size)
}
args::Mode::Zebra => {
// get block data
args::Backend::Zebrad => {
// get block data from zebrad by deserializing the raw block
cmd.args(["getblock", &x.to_string(), "0"]);
let output = cmd_output(&mut cmd)?;

Expand Down

0 comments on commit a206792

Please sign in to comment.