Skip to content

Commit

Permalink
Merge pull request #70 from mempool/junderw/loop-and-broadcast
Browse files Browse the repository at this point in the history
Feature: Configurable loop delay and bitcoind-only broadcast endpoint
  • Loading branch information
wiz authored Dec 15, 2023
2 parents b379d24 + d430e16 commit 8c69110
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bin/electrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn run_server(config: Arc<Config>) -> Result<()> {
}

loop {
if let Err(err) = signal.wait(Duration::from_millis(500), true) {
if let Err(err) = signal.wait(Duration::from_millis(config.main_loop_delay), true) {
info!("stopping server: {}", err);

electrs::util::spawn_thread("shutdown-thread-checker", || {
Expand Down
8 changes: 8 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub struct Config {
pub monitoring_addr: SocketAddr,
pub jsonrpc_import: bool,
pub light_mode: bool,
pub main_loop_delay: u64,
pub address_search: bool,
pub index_unspendables: bool,
pub cors: Option<String>,
Expand Down Expand Up @@ -168,6 +169,12 @@ impl Config {
.long("lightmode")
.help("Enable light mode for reduced storage")
)
.arg(
Arg::with_name("main_loop_delay")
.long("main-loop-delay")
.help("The number of milliseconds the main loop will wait between loops. (Can be shortened with SIGUSR1)")
.default_value("500")
)
.arg(
Arg::with_name("address_search")
.long("address-search")
Expand Down Expand Up @@ -494,6 +501,7 @@ impl Config {
rest_max_mempool_page_size: value_t_or_exit!(m, "rest_max_mempool_page_size", usize),
jsonrpc_import: m.is_present("jsonrpc_import"),
light_mode: m.is_present("light_mode"),
main_loop_delay: value_t_or_exit!(m, "main_loop_delay", u64),
address_search: m.is_present("address_search"),
index_unspendables: m.is_present("index_unspendables"),
cors: m.value_of("cors").map(|s| s.to_string()),
Expand Down
3 changes: 3 additions & 0 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ do
# prepare run-time variables
UTXOS_LIMIT=500
ELECTRUM_TXS_LIMIT=500
MAIN_LOOP_DELAY=500
DAEMON_CONF="${HOME}/${DAEMON}.conf"
HTTP_SOCKET_FILE="${HOME}/socket/esplora-${DAEMON}-${NETWORK}"
RPC_SOCKET_FILE="${HOME}/socket/electrum-${DAEMON}-${NETWORK}"
Expand All @@ -90,6 +91,7 @@ do
if [ "${NODENAME}" = "node201" ];then
UTXOS_LIMIT=9000
ELECTRUM_TXS_LIMIT=9000
MAIN_LOOP_DELAY=14000
fi

# Run the popular address txt file generator before each run
Expand Down Expand Up @@ -127,6 +129,7 @@ do
--network "${NETWORK}" \
--daemon-dir "${HOME}" \
--db-dir "${DB_FOLDER}" \
--main-loop-delay "${MAIN_LOOP_DELAY}" \
--rpc-socket-file "${RPC_SOCKET_FILE}" \
--http-socket-file "${HTTP_SOCKET_FILE}" \
--precache-scripts "${POPULAR_SCRIPTS_FILE}" \
Expand Down

0 comments on commit 8c69110

Please sign in to comment.