choose default ports by network

This commit is contained in:
scilio 2022-08-20 13:45:51 -04:00
parent 1d9e59b7d6
commit 462beab616
2 changed files with 24 additions and 2 deletions

View file

@ -240,6 +240,22 @@ pub fn wallet_owner_secret_path(chain_type: &ChainTypes) -> PathBuf {
path
}
pub fn grin_node_url(chain_type: &ChainTypes) -> SocketAddr {
if *chain_type == ChainTypes::Testnet {
"127.0.0.1:13413".parse().unwrap()
} else {
"127.0.0.1:3413".parse().unwrap()
}
}
pub fn wallet_owner_url(chain_type: &ChainTypes) -> SocketAddr {
if *chain_type == ChainTypes::Testnet {
"127.0.0.1:13420".parse().unwrap()
} else {
"127.0.0.1:3420".parse().unwrap()
}
}
#[cfg(test)]
mod tests {
use super::*;

View file

@ -70,14 +70,20 @@ fn real_main() -> Result<(), Box<dyn std::error::Error>> {
key: secp::random_secret(),
interval_s: round_time.unwrap_or(DEFAULT_INTERVAL),
addr: bind_addr.unwrap_or("0.0.0.0:3000").parse()?,
grin_node_url: grin_node_url.unwrap_or("127.0.0.1:3413").parse()?,
grin_node_url: match grin_node_url {
Some(u) => u.parse()?,
None => config::grin_node_url(&chain_type),
},
grin_node_secret_path: match grin_node_secret_path {
Some(p) => Some(p.to_owned()),
None => config::node_secret_path(&chain_type)
.to_str()
.map(|p| p.to_owned()),
},
wallet_owner_url: wallet_owner_url.unwrap_or("127.0.0.1:3420").parse()?,
wallet_owner_url: match wallet_owner_url {
Some(u) => u.parse()?,
None => config::wallet_owner_url(&chain_type),
},
wallet_owner_secret_path: match wallet_owner_secret_path {
Some(p) => Some(p.to_owned()),
None => config::wallet_owner_secret_path(&chain_type)