Skip to main content

hoprd_localcluster/
cli.rs

1use std::{path::PathBuf, str::FromStr};
2
3use clap::Parser;
4use hopr_primitive_types::prelude::HoprBalance;
5
6use crate::identity::{DEFAULT_CONFIG_HOME, DEFAULT_IDENTITY_PASSWORD, DEFAULT_NUM_NODES};
7
8#[derive(Parser, Debug)]
9#[command(
10    name = "hoprd-localcluster",
11    about = "Run a local HOPR cluster using external processes"
12)]
13pub struct Args {
14    /// Number of nodes to start
15    #[arg(long, default_value_t = DEFAULT_NUM_NODES)]
16    pub size: usize,
17
18    /// Channel funding amount in base units (per channel)
19    #[arg(long, default_value = "1 wxHOPR", value_parser = HoprBalance::from_str)]
20    pub funding_amount: HoprBalance,
21
22    /// Skip channel creation
23    #[arg(long, default_value_t = false)]
24    pub skip_channels: bool,
25
26    /// REST API host to bind (use "auto" to bind 0.0.0.0 and advertise the container IP)
27    #[arg(long, default_value = "localhost")]
28    pub api_host: String,
29
30    /// REST API base port (node index is added)
31    #[arg(long, default_value_t = 3000)]
32    pub api_port_base: u16,
33
34    /// P2P host to bind (use "auto" to detect the container interface IP)
35    #[arg(long, default_value = "localhost")]
36    pub p2p_host: String,
37
38    /// P2P base port (node index is added)
39    #[arg(long, default_value_t = 9000)]
40    pub p2p_port_base: u16,
41
42    /// Base directory for generated configs, identities, DBs, and logs
43    #[arg(long, default_value = DEFAULT_CONFIG_HOME)]
44    pub data_dir: PathBuf,
45
46    /// Docker image containing both Anvil and Blokli (required unless --chain-url is set)
47    #[arg(long, env = "HOPRD_CHAIN_IMAGE", required_unless_present = "chain_url")]
48    pub chain_image: Option<String>,
49
50    /// Base URL for Blokli (e.g. http://chain:8080). If set, localcluster will not start the chain container.
51    #[arg(long, env = "HOPRD_CHAIN_URL")]
52    pub chain_url: Option<String>,
53
54    /// Path to the hoprd binary
55    #[arg(long, default_value = "hoprd")]
56    pub hoprd_bin: PathBuf,
57
58    /// Password used to encrypt identities
59    #[arg(long, default_value = DEFAULT_IDENTITY_PASSWORD)]
60    pub identity_password: String,
61
62    /// API token for hoprd REST API (enables authentication)
63    #[arg(long)]
64    pub api_token: Option<String>,
65}