Skip to content

Make the Python Executable definable as a variable #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions runthenumbers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ OUTPUT_FILE="the_numbers_${TARGET_BLOCK}.txt"
# We'll set this to zero so we can update the console only when there's a new block
LATEST_BLOCK="0"

# Define the path to the python binary (in case you have it installed elsewhere)
PYTHONCMD="/usr/bin/python"

# This will query your node repeatedly until the target block height is reached
while true
do
Expand All @@ -25,12 +28,12 @@ do
fi

# This fetches the current block height from your full node.
CURRENT_BLOCK=$(curl -s --user "${USERNAME}":"${PASSWORD}" --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://${IP_ADDRESS}:${PORT}/ | python -c "import sys, json; print(json.load(sys.stdin)['result'])")
CURRENT_BLOCK=$(curl -s --user "${USERNAME}":"${PASSWORD}" --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://${IP_ADDRESS}:${PORT}/ | ${PYTHONCMD} -c "import sys, json; print(json.load(sys.stdin)['result'])")

# If the block height matches, call gettxoutsetinfo and print to file
if [ $CURRENT_BLOCK = $TARGET_BLOCK ]; then
echo "$CURRENT_BLOCK/$TARGET_BLOCK: running the numbers...";
TXOUTSETINFO=$(curl -s --user "${USERNAME}":"${PASSWORD}" --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "gettxoutsetinfo", "params":[] }' -H 'content-type: text/plain;' http://${IP_ADDRESS}:${PORT}/ | python -c "import sys, json; parsed = json.load(sys.stdin)['result']; print(json.dumps(parsed, indent=2))")
TXOUTSETINFO=$(curl -s --user "${USERNAME}":"${PASSWORD}" --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "gettxoutsetinfo", "params":[] }' -H 'content-type: text/plain;' http://${IP_ADDRESS}:${PORT}/ | ${PYTHONCMD} -c "import sys, json; parsed = json.load(sys.stdin)['result']; print(json.dumps(parsed, indent=2))")
echo
echo
echo "${TXOUTSETINFO}"
Expand Down Expand Up @@ -60,4 +63,4 @@ do
# Query block height every n seconds
sleep 5

done
done