From 1ef942471997a07911fe3791c3773d19aecfd5cf Mon Sep 17 00:00:00 2001 From: Abraham Date: Sun, 15 Mar 2026 00:21:58 -0700 Subject: [PATCH] feat: add chain_data_integrity --- tools/chain_data_integrity.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tools/chain_data_integrity.py diff --git a/tools/chain_data_integrity.py b/tools/chain_data_integrity.py new file mode 100644 index 00000000..3a2ecde7 --- /dev/null +++ b/tools/chain_data_integrity.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +"""RustChain Check data integrity.""" +import json, urllib.request, ssl, os, time +NODE = os.environ.get("RUSTCHAIN_NODE", "https://rustchain.org") +def api(p): + ctx = ssl.create_default_context(); ctx.check_hostname = False; ctx.verify_mode = ssl.CERT_NONE + try: + s = time.time() + r = urllib.request.urlopen(f"{NODE}{p}", timeout=10, context=ctx) + return json.loads(r.read()), round((time.time()-s)*1000, 1) + except: return {}, 0 +def main(): + h, hms = api("/health") + e, ems = api("/epoch") + m, mms = api("/api/miners") + ml = m if isinstance(m, list) else m.get("miners", []) + print(f"Check data integrity") + print(f" {h.get('status','?')} v{h.get('version','?')} | epoch {e.get('epoch', e.get('current_epoch','?'))} | {len(ml)} miners | {hms}ms") +if __name__ == "__main__": + main()