Last active
December 27, 2022 21:02
-
-
Save LarryRuane/35eb30cd2051e3629bbb768a19f0c320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# show heights and timestamps of empty blocks, most recent first (so if using a pruned node, | |
# this will stop when we reach the start of the prune window) | |
from bitcoinrpc.authproxy import AuthServiceProxy | |
import json | |
from datetime import datetime | |
api = AuthServiceProxy("http://lmr:lmr@127.0.0.1:8332") | |
latest_height = api.getblockcount() | |
for i in range(latest_height, 1, -1): | |
bhash = api.getblockhash(i) | |
try: | |
block = api.getblock("{}".format(bhash)) | |
except: break | |
if block['nTx'] == 1: | |
print(i, datetime.utcfromtimestamp(block['time']).strftime('%Y-%m-%d %H:%M:%S')) | |
""" current output, as of 12/21/2022: | |
768274 2022-12-20 23:17:43 | |
768024 2022-12-19 02:57:05 | |
767948 2022-12-18 15:23:06 | |
767807 2022-12-17 15:25:34 | |
766983 2022-12-11 21:58:08 | |
766751 2022-12-10 10:29:37 | |
766411 2022-12-08 04:30:01 | |
""" |
The script's runtime depends on your node's prune limit. With the default of 550 MB, the script didn't find any empty blocks at all. So I increased the prune setting to 5000 (5 GB), and then the script generated those results in 3.5 minutes. This is on a midrange laptop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, how long did the script take to run?