Skip to content

Commit 202c289

Browse files
refactor(readability): define specific time units in variables (#1470)
1 parent 20cdc21 commit 202c289

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

nodebuilder

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ check_internet_to_address()
2929
{
3030
check_internet_address=$1
3131
readonly CHECK_INTERNET_PORT='443'
32-
readonly CHECK_INTERNET_TIMEOUT='10'
32+
readonly CHECK_INTERNET_TIMEOUT_SECONDS='10'
3333
# shellcheck disable=SC2015
3434
command -v torsocks > /dev/null 2>&1 && [ "${TARGET_OPERATING_SYSTEM}" != 'Darwin' ] &&
35-
torsocks curl --silent --output /dev/null --retry 2 --connect-timeout "${CHECK_INTERNET_TIMEOUT}" "https://${check_internet_address}:${CHECK_INTERNET_PORT}" > /dev/null ||
36-
curl --silent --output /dev/null --retry 5 --connect-timeout "${CHECK_INTERNET_TIMEOUT}" "https://${check_internet_address}:${CHECK_INTERNET_PORT}" > /dev/null
35+
torsocks curl --silent --output /dev/null --retry 2 --connect-timeout "${CHECK_INTERNET_TIMEOUT_SECONDS}" "https://${check_internet_address}:${CHECK_INTERNET_PORT}" > /dev/null ||
36+
curl --silent --output /dev/null --retry 5 --connect-timeout "${CHECK_INTERNET_TIMEOUT_SECONDS}" "https://${check_internet_address}:${CHECK_INTERNET_PORT}" > /dev/null
3737
}
3838

3939
clear_the_terminal()
@@ -1730,12 +1730,12 @@ else
17301730
fi
17311731

17321732
log_info 'Checking the RPC status.'
1733-
readonly BITCOIN_RPC_TIMEOUT=300
1734-
if ! bitcoin-cli --datadir="${BITCOIN_DATA_DIRECTORY}" --rpcwait --rpcwaittimeout="${BITCOIN_RPC_TIMEOUT}" getrpcinfo > /dev/null; then
1735-
throw_error "RPC communication failed after ${BITCOIN_RPC_TIMEOUT} seconds."
1733+
readonly BITCOIN_RPC_TIMEOUT_SECONDS=300
1734+
if ! bitcoin-cli --datadir="${BITCOIN_DATA_DIRECTORY}" --rpcwait --rpcwaittimeout="${BITCOIN_RPC_TIMEOUT_SECONDS}" getrpcinfo > /dev/null; then
1735+
throw_error "RPC communication failed after ${BITCOIN_RPC_TIMEOUT_SECONDS} seconds."
17361736
fi
17371737

1738-
readonly SLEEP_TIME='10'
1738+
readonly SLEEP_TIME_SECONDS='10'
17391739
blockchain_info=$(bitcoin-cli --datadir="${BITCOIN_DATA_DIRECTORY}" --rpcwait getblockchaininfo)
17401740
ibd_status=$(echo "${blockchain_info}" | jq '.initialblockdownload')
17411741

@@ -1749,9 +1749,9 @@ if [ "${ibd_status}" = 'true' ]; then
17491749
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target > /dev/null 2>&1
17501750
fi
17511751
log_info "Close this Terminal window by clicking on the 'X'."
1752-
log_info "This screen will refresh in ${SLEEP_TIME} seconds."
1752+
log_info "This screen will refresh in ${SLEEP_TIME_SECONDS} seconds."
17531753
fi
1754-
sleep "${SLEEP_TIME}"
1754+
sleep "${SLEEP_TIME_SECONDS}"
17551755
else
17561756
log_info 'Your node has already synced the blockchain.'
17571757
fi
@@ -1831,8 +1831,8 @@ while [ "${ibd_status}" = 'true' ]; do
18311831

18321832
printf '%s\n\n' 'The chain sync can take several days or even weeks.'
18331833
printf '%s\n' "Close this Terminal window by clicking on the 'X'."
1834-
printf '%s' "This screen will refresh in ${SLEEP_TIME} seconds."
1835-
sleep "${SLEEP_TIME}"
1834+
printf '%s' "This screen will refresh in ${SLEEP_TIME_SECONDS} seconds."
1835+
sleep "${SLEEP_TIME_SECONDS}"
18361836

18371837
blockchain_info=$(bitcoin-cli --datadir="${BITCOIN_DATA_DIRECTORY}" --rpcwait getblockchaininfo)
18381838
printf '\n'

0 commit comments

Comments
 (0)