mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
default to sane value for missing owner_api_listen_port (#2484)
* default to sane value for missing owner_api_listen_port * add comment for owner_api_listen_port and cleanup previous comment * get rid of TODO
This commit is contained in:
parent
d1de3b0d6e
commit
507da6a9fd
2 changed files with 23 additions and 6 deletions
|
@ -365,13 +365,20 @@ fn comments() -> HashMap<String, String> {
|
||||||
retval.insert(
|
retval.insert(
|
||||||
"api_listen_port".to_string(),
|
"api_listen_port".to_string(),
|
||||||
"
|
"
|
||||||
#port for wallet listener
|
|
||||||
|
|
||||||
#path of TLS certificate file, self-signed certificates are not supported
|
#path of TLS certificate file, self-signed certificates are not supported
|
||||||
#tls_certificate_file = \"\"
|
#tls_certificate_file = \"\"
|
||||||
#private key for the TLS certificate
|
#private key for the TLS certificate
|
||||||
#tls_certificate_key = \"\"
|
#tls_certificate_key = \"\"
|
||||||
|
|
||||||
|
#port for wallet listener
|
||||||
|
"
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
|
||||||
|
retval.insert(
|
||||||
|
"owner_api_listen_port".to_string(),
|
||||||
|
"
|
||||||
|
#port for wallet owner api
|
||||||
"
|
"
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
|
@ -418,7 +425,7 @@ fn comments() -> HashMap<String, String> {
|
||||||
"no_commit_cache".to_string(),
|
"no_commit_cache".to_string(),
|
||||||
"
|
"
|
||||||
#If true, don't store calculated commits in the database
|
#If true, don't store calculated commits in the database
|
||||||
#better privacy, but at a performance cost of having to
|
#better privacy, but at a performance cost of having to
|
||||||
#re-calculate commits every time they're used
|
#re-calculate commits every time they're used
|
||||||
"
|
"
|
||||||
.to_string(),
|
.to_string(),
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub struct WalletConfig {
|
||||||
// The port this wallet will run on
|
// The port this wallet will run on
|
||||||
pub api_listen_port: u16,
|
pub api_listen_port: u16,
|
||||||
// The port this wallet's owner API will run on
|
// The port this wallet's owner API will run on
|
||||||
pub owner_api_listen_port: u16,
|
pub owner_api_listen_port: Option<u16>,
|
||||||
/// Location of the secret for basic auth on the Owner API
|
/// Location of the secret for basic auth on the Owner API
|
||||||
pub api_secret_path: Option<String>,
|
pub api_secret_path: Option<String>,
|
||||||
/// Location of the node api secret for basic auth on the Grin API
|
/// Location of the node api secret for basic auth on the Grin API
|
||||||
|
@ -74,7 +74,7 @@ impl Default for WalletConfig {
|
||||||
chain_type: Some(ChainTypes::Mainnet),
|
chain_type: Some(ChainTypes::Mainnet),
|
||||||
api_listen_interface: "127.0.0.1".to_string(),
|
api_listen_interface: "127.0.0.1".to_string(),
|
||||||
api_listen_port: 3415,
|
api_listen_port: 3415,
|
||||||
owner_api_listen_port: 3420,
|
owner_api_listen_port: Some(WalletConfig::default_owner_api_listen_port()),
|
||||||
api_secret_path: Some(".api_secret".to_string()),
|
api_secret_path: Some(".api_secret".to_string()),
|
||||||
node_api_secret_path: Some(".api_secret".to_string()),
|
node_api_secret_path: Some(".api_secret".to_string()),
|
||||||
check_node_api_http_addr: "http://127.0.0.1:3413".to_string(),
|
check_node_api_http_addr: "http://127.0.0.1:3413".to_string(),
|
||||||
|
@ -94,8 +94,18 @@ impl WalletConfig {
|
||||||
format!("{}:{}", self.api_listen_interface, self.api_listen_port)
|
format!("{}:{}", self.api_listen_interface, self.api_listen_port)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn default_owner_api_listen_port() -> u16 {
|
||||||
|
3420
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Use value from config file, defaulting to sensible value if missing.
|
||||||
|
pub fn owner_api_listen_port(&self) -> u16 {
|
||||||
|
self.owner_api_listen_port
|
||||||
|
.unwrap_or(WalletConfig::default_owner_api_listen_port())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn owner_api_listen_addr(&self) -> String {
|
pub fn owner_api_listen_addr(&self) -> String {
|
||||||
format!("127.0.0.1:{}", self.owner_api_listen_port)
|
format!("127.0.0.1:{}", self.owner_api_listen_port())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue