Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub struct Config {
pub daemon_conn_max_age: Option<Duration>,
pub cookie: Option<String>,
pub electrum_rpc_addr: SocketAddr,
pub electrum_rpc_conn_max_age: Option<Duration>,
pub http_addr: SocketAddr,
pub http_socket_file: Option<PathBuf>,
pub monitoring_addr: SocketAddr,
Expand Down Expand Up @@ -156,6 +157,13 @@ impl Config {
.help("Electrum server JSONRPC 'addr:port' to listen on (default: '127.0.0.1:50001' for mainnet, '127.0.0.1:60001' for testnet3, '127.0.0.1:40001' for testnet4 and '127.0.0.1:60401' for regtest)")
.takes_value(true),
)
.arg(
Arg::with_name("electrum_rpc_conn_max_age")
.long("electrum-rpc-conn-max-age")
.help("Maximum age (in seconds) of inbound Electrum RPC TCP connections. Each connection is closed at a randomly selected age between 50% and 100% of this value so clients reconnect gradually and load balancers can redistribute them. 0 = unlimited / never disconnect (default)")
.default_value("0")
.takes_value(true),
)
.arg(
Arg::with_name("http_addr")
.long("http-addr")
Expand Down Expand Up @@ -451,6 +459,11 @@ impl Config {
.unwrap_or(&format!("127.0.0.1:{}", default_electrum_port)),
"Electrum RPC",
);
let electrum_rpc_conn_max_age: Option<Duration> =
match value_t_or_exit!(m, "electrum_rpc_conn_max_age", u64) {
0 => None, // 0 = unlimited / never disconnect
secs => Some(Duration::from_secs(secs)),
};
let http_addr: SocketAddr = str_to_socketaddr(
m.value_of("http_addr")
.unwrap_or(&format!("127.0.0.1:{}", default_http_port)),
Expand Down Expand Up @@ -519,6 +532,7 @@ impl Config {
cookie,
utxos_limit: value_t_or_exit!(m, "utxos_limit", usize),
electrum_rpc_addr,
electrum_rpc_conn_max_age,
electrum_txs_limit: value_t_or_exit!(m, "electrum_txs_limit", usize),
electrum_banner,
rpc_logging: {
Expand Down
Loading
Loading