diff --git a/tools/find-block-height-gaps/main.py b/tools/find-block-height-gaps/main.py index a932afc..2b4c41a 100644 --- a/tools/find-block-height-gaps/main.py +++ b/tools/find-block-height-gaps/main.py @@ -27,10 +27,10 @@ def get_args(): SELECT_CHAINS_QUERY = "SELECT id FROM chains WHERE chain_id=%s;" GAPS_QUERY = """ -SELECT height + 1 AS gap_start, +SELECT height + 1 AS gap_start, next_height - 1 AS gap_end FROM ( - SELECT height, + SELECT height, LEAD(height) OVER (ORDER BY height) AS next_height FROM blocks WHERE blockchain_id = %s ) nr @@ -62,7 +62,7 @@ def flatten_and_fill(gaps): rec = cur.fetchone() if rec is None: raise Exception(f"Chain ID {chain_id} not found") - + print("Executing gap finder...") with conn.cursor() as cur: cur.execute(GAPS_QUERY, (rec[0],)) @@ -81,4 +81,4 @@ def flatten_and_fill(gaps): print(err) traceback.print_exc() finally: - conn.close() \ No newline at end of file + conn.close()