1
0
Fork 0
mirror of https://github.com/romanz/electrs.git synced 2025-02-23 14:50:45 +01:00

Allow single-sync invocation using --sync-once commandline flag

This commit is contained in:
Roman Zeyde 2021-09-11 11:01:05 +03:00
parent 269e756383
commit f5df00f631
3 changed files with 9 additions and 1 deletions

View file

@ -85,6 +85,10 @@ default = "10"
name = "ignore_mempool"
doc = "Don't sync mempool - queries will show only confirmed transactions."
[[switch]]
name = "sync_once"
doc = "Exit after the initial sync is over (don't start Electrum server)."
[[param]]
name = "index_lookup_limit"
type = "usize"

View file

@ -9,7 +9,9 @@ fn main() -> Result<()> {
tracker
.sync(&Daemon::connect(&config)?)
.context("initial sync failed")?;
if config.sync_once {
return Ok(());
}
// re-connect after initial sync (due to possible timeout during compaction)
server::run(&config, Rpc::new(&config, tracker)?).context("server failed")
}

View file

@ -133,6 +133,7 @@ pub struct Config {
pub index_batch_size: usize,
pub index_lookup_limit: Option<usize>,
pub ignore_mempool: bool,
pub sync_once: bool,
pub server_banner: String,
pub args: Vec<String>,
}
@ -294,6 +295,7 @@ impl Config {
index_batch_size: config.index_batch_size,
index_lookup_limit,
ignore_mempool: config.ignore_mempool,
sync_once: config.sync_once,
server_banner: config.server_banner,
args: args.map(|a| a.into_string().unwrap()).collect(),
};