Idea: Generate the popular scripts before startup

This commit is contained in:
junderw 2023-09-18 22:36:50 -07:00
parent 811c6c4677
commit 3e283190af
No known key found for this signature in database
GPG Key ID: B256185D3A971908
6 changed files with 23 additions and 11374 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,8 +20,6 @@ do
-- \
--network liquid \
--http-socket-file "${HOME}/socket/esplora-liquid-mainnet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--precache-threads 100 \
--asset-db-path "${HOME}/asset_registry_db" \
--daemon-dir "${HOME}" \
--db-dir /electrs \

View File

@ -20,8 +20,6 @@ do
-- \
--network liquidtestnet \
--http-socket-file "${HOME}/socket/esplora-liquid-testnet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--precache-threads 100 \
--asset-db-path "${HOME}/asset_registry_testnet_db" \
--daemon-dir "${HOME}" \
--db-dir "/electrs" \

View File

@ -13,12 +13,34 @@ BITCOIN_RPC_PASS=$(grep 'rpcpassword=' ${HOME}/bitcoin.conf|cut -d = -f2|head -1
until false
do
cd "${HOME}/electrs"
# MAINNET ONLY Run the popular address txt file generator before each run
PS_FOLDER=/tmp/electrs-popular-scripts
rm -rf "${PS_FOLDER}"
mkdir -p "${PS_FOLDER}"
## Use 128 threads to generate the txt file (lots of iowait, so 2x~4x core count is ok)
## Only pick up addresses with 101 history events or more
## (Without lowering MIN_HISTORY_ITEMS_TO_CACHE this is the lowest we can go)
## It prints out progress to STDERR
HIGH_USAGE_THRESHOLD=101 \
JOB_THREAD_COUNT=128 \
cargo run \
--release \
--bin popular-scripts \
-- \
--db-dir "/electrs" \
> "${PS_FOLDER}/popular-scripts.txt"
## Sorted and deduplicated just in case
sort "${PS_FOLDER}/popular-scripts.txt" | uniq > "${PS_FOLDER}/tmp.txt"
mv "${PS_FOLDER}/tmp.txt" "${PS_FOLDER}/popular-scripts.txt"
# Run the electrs process (Note: db-dir is used in both commands)
cargo run \
--release \
--bin electrs \
-- \
--http-socket-file "${HOME}/socket/esplora-bitcoin-mainnet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--precache-scripts "${PS_FOLDER}/popular-scripts.txt" \
--precache-threads 100 \
--daemon-dir "${HOME}" \
--db-dir "/electrs" \

View File

@ -19,8 +19,6 @@ do
-- \
--network signet \
--http-socket-file "${HOME}/socket/esplora-bitcoin-signet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--precache-threads 100 \
--daemon-dir "${HOME}" \
--db-dir "/electrs" \
--cookie "${BITCOIN_RPC_USER}:${BITCOIN_RPC_PASS}" \

View File

@ -19,8 +19,6 @@ do
-- \
--network testnet \
--http-socket-file "${HOME}/socket/esplora-bitcoin-testnet" \
--precache-scripts "${HOME}/electrs/contrib/popular-scripts.txt" \
--precache-threads 100 \
--daemon-dir "${HOME}" \
--db-dir "/electrs" \
--cookie "${BITCOIN_RPC_USER}:${BITCOIN_RPC_PASS}" \