1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Add signet-magic to config

This commit is contained in:
Sosthene00 2022-08-11 15:42:36 +02:00
parent b94450c6a5
commit ad864bf8af
2 changed files with 16 additions and 0 deletions

View File

@ -131,3 +131,8 @@ default = "concat!(\"Welcome to electrs \", env!(\"CARGO_PKG_VERSION\"), \" (Ele
name = "log_filters" name = "log_filters"
type = "String" type = "String"
doc = "Logging filters, overriding `RUST_LOG` environment variable (see https://docs.rs/env_logger/ for details)" doc = "Logging filters, overriding `RUST_LOG` environment variable (see https://docs.rs/env_logger/ for details)"
[[param]]
name = "signet_magic"
type = "u32"
doc = "network magic for custom signet network (signet only)"

View File

@ -144,6 +144,7 @@ pub struct Config {
pub sync_once: bool, pub sync_once: bool,
pub disable_electrum_rpc: bool, pub disable_electrum_rpc: bool,
pub server_banner: String, pub server_banner: String,
pub signet_magic: u32,
pub args: Vec<String>, pub args: Vec<String>,
} }
@ -231,6 +232,15 @@ impl Config {
Network::Signet => 34224, Network::Signet => 34224,
}; };
let magic = match (config.network, config.signet_magic) {
(Network::Signet, Some(magic)) => magic,
(network, None) => network.magic(),
(_, Some(_)) => {
eprintln!("Error: signet magic only available on signet");
std::process::exit(1);
},
};
let daemon_rpc_addr: SocketAddr = config.daemon_rpc_addr.map_or( let daemon_rpc_addr: SocketAddr = config.daemon_rpc_addr.map_or(
(DEFAULT_SERVER_ADDRESS, default_daemon_rpc_port).into(), (DEFAULT_SERVER_ADDRESS, default_daemon_rpc_port).into(),
ResolvAddr::resolve_or_exit, ResolvAddr::resolve_or_exit,
@ -323,6 +333,7 @@ impl Config {
sync_once: config.sync_once, sync_once: config.sync_once,
disable_electrum_rpc: config.disable_electrum_rpc, disable_electrum_rpc: config.disable_electrum_rpc,
server_banner: config.server_banner, server_banner: config.server_banner,
signet_magic: magic,
args: args.map(|a| a.into_string().unwrap()).collect(), args: args.map(|a| a.into_string().unwrap()).collect(),
}; };
eprintln!( eprintln!(