Skip to content

Commit

Permalink
chore: add bootnodes,external-ip cli to bridge to support hive test (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
KolbyML authored and ltfschoen committed Nov 1, 2023
1 parent 03de8f4 commit d41df94
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
14 changes: 14 additions & 0 deletions portal-bridge/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ pub struct BridgeConfig {
#[arg(long, help = "Url for metrics reporting")]
pub metrics_url: Option<Url>,

#[arg(
default_value = "default",
long = "bootnodes",
help = "One or more comma-delimited base64-encoded ENR's or multiaddr strings of peers to initially add to the local routing table"
)]
pub bootnodes: String,

#[arg(
default_value = "none",
long = "external-ip",
help = "(Only use this if you are behind a NAT) The address which will be advertised to peers (in an ENR). Changing it does not change which address trin binds to, ex: 127.0.0.1"
)]
pub external_ip: String,

#[command(subcommand)]
pub client_type: ClientType,
}
Expand Down
16 changes: 15 additions & 1 deletion portal-bridge/src/client_handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ pub fn fluffy_handle(
.arg(format!("--metrics-address:{address}"))
.arg(format!("--metrics-port:{port}"));
}
if bridge_config.bootnodes != "default" {
for enr in bridge_config.bootnodes.split(',') {
command.args(["--bootstrap-node", enr]);
}
}
if !bridge_config.external_ip.is_empty() {
command.arg(format!("--nat:extip:{}", bridge_config.external_ip));
}
Ok(command.spawn()?)
}

Expand Down Expand Up @@ -67,7 +75,13 @@ pub fn trin_handle(
&format!("http://127.0.0.1:{rpc_port}"),
])
.args(["--discovery-port", &format!("{udp_port}")])
.args(["--bootnodes", "default"]);
.args(["--bootnodes", &bridge_config.bootnodes]);
if !bridge_config.external_ip.is_empty() {
command.args([
"--external-address",
&format!("{}:{}", bridge_config.external_ip, udp_port),
]);
}
if let Some(metrics_url) = bridge_config.metrics_url {
let url: String = metrics_url.into();
command.args(["--enable-metrics-with-url", &url]);
Expand Down

0 comments on commit d41df94

Please sign in to comment.