1
0
Fork 0
mirror of https://github.com/romanz/electrs.git synced 2025-02-24 06:57:53 +01:00

Allow configuring wait duration

This commit is contained in:
Roman Zeyde 2020-06-13 18:15:03 +03:00
parent 2f2b1c9ef1
commit 5ae93db59e
No known key found for this signature in database
GPG key ID: 87CAE5FA46917CBB
3 changed files with 10 additions and 2 deletions

View file

@ -69,6 +69,12 @@ doc = "Prometheus monitoring 'addr:port' to listen on (default: 127.0.0.1:4224 f
name = "jsonrpc_import"
doc = "Use JSONRPC instead of directly importing blk*.dat files. Useful for remote full node or low memory system"
[[param]]
name = "wait_duration_secs"
type = "u64"
doc = "Duration to wait between bitcoind polling"
default = "5"
[[param]]
name = "index_batch_size"
type = "usize"

View file

@ -7,7 +7,6 @@ extern crate log;
use error_chain::ChainedError;
use std::process;
use std::sync::Arc;
use std::time::Duration;
use electrs::{
app::App,
@ -72,7 +71,7 @@ fn run_server(config: &Config) -> Result<()> {
RPC::start(config.electrum_rpc_addr, query.clone(), &metrics, relayfee)
})
.notify(); // update subscribed clients
if let Err(err) = signal.wait(Duration::from_secs(5)) {
if let Err(err) = signal.wait(config.wait_duration) {
info!("stopping server: {}", err);
break;
}

View file

@ -10,6 +10,7 @@ use std::net::ToSocketAddrs;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
use stderrlog;
use crate::daemon::CookieGetter;
@ -131,6 +132,7 @@ pub struct Config {
pub electrum_rpc_addr: SocketAddr,
pub monitoring_addr: SocketAddr,
pub jsonrpc_import: bool,
pub wait_duration: Duration,
pub index_batch_size: usize,
pub bulk_index_threads: usize,
pub tx_cache_size: usize,
@ -262,6 +264,7 @@ impl Config {
electrum_rpc_addr,
monitoring_addr,
jsonrpc_import: config.jsonrpc_import,
wait_duration: Duration::from_secs(config.wait_duration_secs),
index_batch_size: config.index_batch_size,
bulk_index_threads: config.bulk_index_threads,
tx_cache_size: (config.tx_cache_size_mb * MB) as usize,