mirror of
https://github.com/romanz/electrs.git
synced 2026-08-15 12:50:18 +02:00
Allow disabling Electrum RPC while continuing indexing
This commit is contained in:
parent
fbda004ecb
commit
a552a2bb2d
3 changed files with 12 additions and 5 deletions
|
|
@ -96,6 +96,10 @@ default = "10"
|
|||
name = "ignore_mempool"
|
||||
doc = "Don't sync mempool - queries will show only confirmed transactions."
|
||||
|
||||
[[switch]]
|
||||
name = "disable_electrum_rpc"
|
||||
doc = "Disable Electrum RPC server - only sync and index blocks."
|
||||
|
||||
[[switch]]
|
||||
name = "sync_once"
|
||||
doc = "Exit after the initial sync is over (don't start Electrum server)."
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ pub struct Config {
|
|||
pub auto_reindex: bool,
|
||||
pub ignore_mempool: bool,
|
||||
pub sync_once: bool,
|
||||
pub disable_electrum_rpc: bool,
|
||||
pub server_banner: String,
|
||||
pub args: Vec<String>,
|
||||
}
|
||||
|
|
@ -308,6 +309,7 @@ impl Config {
|
|||
auto_reindex: config.auto_reindex,
|
||||
ignore_mempool: config.ignore_mempool,
|
||||
sync_once: config.sync_once,
|
||||
disable_electrum_rpc: config.disable_electrum_rpc,
|
||||
server_banner: config.server_banner,
|
||||
args: args.map(|a| a.into_string().unwrap()).collect(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -67,13 +67,14 @@ fn serve() -> Result<()> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
let listener = TcpListener::bind(config.electrum_rpc_addr)?;
|
||||
info!("serving Electrum RPC on {}", listener.local_addr()?);
|
||||
let new_block_rx = rpc.new_block_notification();
|
||||
|
||||
let (server_tx, server_rx) = unbounded();
|
||||
spawn("accept_loop", || accept_loop(listener, server_tx)); // detach accepting thread
|
||||
if !config.disable_electrum_rpc {
|
||||
let listener = TcpListener::bind(config.electrum_rpc_addr)?;
|
||||
info!("serving Electrum RPC on {}", listener.local_addr()?);
|
||||
spawn("accept_loop", || accept_loop(listener, server_tx)); // detach accepting thread
|
||||
};
|
||||
|
||||
let new_block_rx = rpc.new_block_notification();
|
||||
let mut peers = HashMap::<usize, Peer>::new();
|
||||
loop {
|
||||
select! {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue