#!/bin/bash
# #87: gold/creates.json lost pool creates for blocks 82,129,000-83,476,700 (561 pools: why p204 pools after 8 Oct 16:06 have no create_to).
# Drop creates >= 82,129,000, reset scan head there, rerun gold_inc (rescans and tags). Backup first (zstd).
set -e
cd /opt/sw/harness/gold
zstd -q -3 -f creates.json -o ../creates.json.bak9oct.zst
python3 -I - <<'P'
import json
L=json.load(open('creates.json')); K=[x for x in L if x['blk']<82129000]; print(len(L),len(K))
json.dump(K,open('creates.json.new','w'))
P
mv creates.json.new creates.json
echo '{"next": 82129000}' > creates_head.json; echo '{"next": 82129000}' > tags_state.json
cd ..; flock /tmp/hx-inc.lock nice -n10 ionice -c3 timeout 3000 python3 -u gold_inc.py >> inc.log 2>&1
