diff --git a/miners/fingerprint_checks.py b/miners/fingerprint_checks.py new file mode 100644 index 000000000..8675d91ae --- /dev/null +++ b/miners/fingerprint_checks.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 +""" +Platform-aware fingerprint checks wrapper. + +Automatically detects the current platform and delegates to the +platform-specific fingerprint_checks module (miners//). + +Usage: + python3 miners/fingerprint_checks.py +""" + +import importlib.util +import os +import platform +import sys + +_script_dir = os.path.dirname(os.path.abspath(__file__)) +_platform = platform.system().lower() + +_subdir = {"linux": "linux", "windows": "windows", "darwin": "macos"}.get(_platform, "linux") +_fp_path = os.path.join(_script_dir, _subdir, "fingerprint_checks.py") + +if not os.path.exists(_fp_path): + print(f"Error: no fingerprint_checks.py found for platform '{_platform}'", file=sys.stderr) + print(f"Expected at: {_fp_path}", file=sys.stderr) + sys.exit(1) + +_spec = importlib.util.spec_from_file_location(f"fingerprint_checks_{_subdir}", _fp_path) +_mod = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_mod) + +# Re-export all public symbols for backward compatibility +for _attr in dir(_mod): + if not _attr.startswith("_"): + globals()[_attr] = getattr(_mod, _attr) + +if __name__ == "__main__": + # If the module has a main-like entry point, run it + if hasattr(_mod, "main"): + _mod.main() + else: + print(f"fingerprint_checks ({_platform}) loaded successfully.") + print(f"Available functions: {[a for a in dir(_mod) if not a.startswith('_')]}") \ No newline at end of file diff --git a/node/rustchain_v2_integrated_v2.2.1_rip200.py b/node/rustchain_v2_integrated_v2.2.1_rip200.py index 78dac50d2..2e2a9fdee 100644 --- a/node/rustchain_v2_integrated_v2.2.1_rip200.py +++ b/node/rustchain_v2_integrated_v2.2.1_rip200.py @@ -9005,7 +9005,12 @@ def _tip_age_slots(): try: with sqlite3.connect(DB_PATH, timeout=3) as db: row = db.execute("SELECT slot FROM headers ORDER BY slot DESC LIMIT 1").fetchone() - return 0 if row else None + if row is None: + return None + latest_slot = row[0] + now_slot = current_slot() + age = now_slot - latest_slot + return max(0, age) except Exception: return None diff --git a/tools/rustchain-health.py b/tools/rustchain-health.py index e93afa53c..e17c81a81 100644 --- a/tools/rustchain-health.py +++ b/tools/rustchain-health.py @@ -275,7 +275,8 @@ def render(snapshot: Dict[str, Any]) -> str: # ── Overall ─── all_ok = (h.get("ok", False) and h["reachable"] and e["reachable"] - and m["reachable"]) + and m["reachable"] + and t["reachable"]) lines.append(dim(" " + "─" * w)) if all_ok: lines.append(f" {green(bold('STATUS: ALL SYSTEMS OPERATIONAL'))}") @@ -358,7 +359,8 @@ def run_once() -> int: all_ok = (snapshot["health"].get("ok", False) and snapshot["health"]["reachable"] and snapshot["epoch"]["reachable"] - and snapshot["miners"]["reachable"]) + and snapshot["miners"]["reachable"] + and snapshot["tip"]["reachable"]) return 0 if all_ok else 1 if args.watch > 0: