Skip to content

Commit

Permalink
refactor: rename jrpc cli names (#840)
Browse files Browse the repository at this point in the history
Clarify names of options
  • Loading branch information
stringhandler authored Jan 25, 2024
1 parent b3a5e2e commit 7448b4f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
24 changes: 12 additions & 12 deletions applications/tari_validator_node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ pub struct Cli {
#[clap(long, aliases = &["tracing", "enable-tracing"])]
pub tracing_enabled: bool,
/// Bind address for JSON-rpc server
#[clap(long, alias = "rpc-address")]
pub json_rpc_address: Option<SocketAddr>,
#[clap(long, alias = "http-ui-address")]
pub http_ui_address: Option<SocketAddr>,
#[clap(long, env = "TARI_VN_UI_CONNECT_ADDRESS")]
pub ui_connect_address: Option<String>,
#[clap(long, alias = "json-rpc-address")]
pub json_rpc_listener_address: Option<SocketAddr>,
#[clap(long, env = "TARI_VN_HTTP_UI_LISTENER_ADDRESS", alias = "http-ui-address")]
pub http_ui_listener_address: Option<SocketAddr>,
#[clap(long, env = "TARI_VN_JSON_RPC_PUBLIC_ADDRESS")]
pub json_rpc_public_address: Option<String>,
#[clap(long, short = 's')]
pub peer_seeds: Vec<String>,
#[clap(long)]
Expand All @@ -66,21 +66,21 @@ impl ConfigOverrideProvider for Cli {
overrides.push(("validator_node.override_from".to_string(), network.to_string()));
overrides.push(("p2p.seeds.override_from".to_string(), network.to_string()));

if let Some(ref json_rpc_address) = self.json_rpc_address {
if let Some(ref json_rpc_address) = self.json_rpc_listener_address {
overrides.push((
"validator_node.json_rpc_address".to_string(),
"validator_node.json_rpc_listener_address".to_string(),
json_rpc_address.to_string(),
));
}
if let Some(ref ui_connect_address) = self.ui_connect_address {
if let Some(ref ui_connect_address) = self.json_rpc_public_address {
overrides.push((
"validator_node.ui_connect_address".to_string(),
"validator_node.json_rpc_public_address".to_string(),
ui_connect_address.to_string(),
));
}
if let Some(ref http_ui_address) = self.http_ui_address {
if let Some(ref http_ui_address) = self.http_ui_listener_address {
overrides.push((
"validator_node.http_ui_address".to_string(),
"validator_node.http_ui_listener_address".to_string(),
http_ui_address.to_string(),
));
}
Expand Down
12 changes: 6 additions & 6 deletions applications/tari_validator_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ pub struct ValidatorNodeConfig {
/// GRPC address of the validator node application
pub grpc_address: Option<Multiaddr>,
/// JSON-RPC address of the validator node application
pub json_rpc_address: Option<SocketAddr>,
pub json_rpc_listener_address: Option<SocketAddr>,
/// The jrpc address where the UI should connect (it can be the same as the json_rpc_address, but doesn't have to
/// be), if this will be None, then the listen_addr will be used.
pub ui_connect_address: Option<String>,
pub json_rpc_public_address: Option<String>,
/// The address of the HTTP UI
pub http_ui_address: Option<SocketAddr>,
pub http_ui_listener_address: Option<SocketAddr>,
/// The node will re-register each epoch
pub auto_register: bool,
/// Template config
Expand Down Expand Up @@ -140,9 +140,9 @@ impl Default for ValidatorNodeConfig {
p2p: P2pConfig::default(),
rpc: RpcConfig::default(),
grpc_address: Some("/ip4/127.0.0.1/tcp/18144".parse().unwrap()),
json_rpc_address: Some("127.0.0.1:18200".parse().unwrap()),
ui_connect_address: None,
http_ui_address: Some("127.0.0.1:5001".parse().unwrap()),
json_rpc_listener_address: Some("127.0.0.1:18200".parse().unwrap()),
json_rpc_public_address: None,
http_ui_listener_address: Some("127.0.0.1:5001".parse().unwrap()),
auto_register: true,
templates: TemplateConfig::default(),
no_fees: false,
Expand Down
6 changes: 3 additions & 3 deletions applications/tari_validator_node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,18 @@ pub async fn run_validator_node(config: &ApplicationConfig, shutdown_signal: Shu
info!(target: LOG_TARGET, "🚀 Node started: {}", info);

// Run the JSON-RPC API
let mut jrpc_address = config.validator_node.json_rpc_address;
let mut jrpc_address = config.validator_node.json_rpc_listener_address;
if let Some(jrpc_address) = jrpc_address.as_mut() {
info!(target: LOG_TARGET, "🌐 Started JSON-RPC server on {}", jrpc_address);
let handlers = JsonRpcHandlers::new(wallet_client, base_node_client, &services);
*jrpc_address = spawn_json_rpc(*jrpc_address, handlers)?;
// Run the http ui
if let Some(address) = config.validator_node.http_ui_address {
if let Some(address) = config.validator_node.http_ui_listener_address {
task::spawn(run_http_ui_server(
address,
config
.validator_node
.ui_connect_address
.json_rpc_public_address
.clone()
.unwrap_or_else(|| jrpc_address.to_string()),
));
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/src/validator_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ pub async fn spawn_validator_node(
// config.validator_node.public_address =
// Some(config.validator_node.p2p.transport.tcp.listener_address.clone());
config.validator_node.p2p.enable_mdns = false;
config.validator_node.json_rpc_address = Some(format!("127.0.0.1:{}", json_rpc_port).parse().unwrap());
config.validator_node.http_ui_address = Some(format!("127.0.0.1:{}", http_ui_port).parse().unwrap());
config.validator_node.json_rpc_listener_address = Some(format!("127.0.0.1:{}", json_rpc_port).parse().unwrap());
config.validator_node.http_ui_listener_address = Some(format!("127.0.0.1:{}", http_ui_port).parse().unwrap());
config.validator_node.p2p.listener_port = port;

config.validator_node.no_fees = !enable_fees;
Expand Down

0 comments on commit 7448b4f

Please sign in to comment.