| Server IP : 54.37.205.81 / Your IP : 216.73.216.76 Web Server : nginx/1.22.1 System : Linux vps-249481fa 6.1.0-50-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.176-1 (2026-07-02) x86_64 User : debian ( 1000) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /opt/ccp-ai-gateway/ |
Upload File : |
import os
import sys
import json
import traceback
sys.path.insert(0, "/opt/ccp-ai-gateway")
import app as ccp
def load_rows():
if not os.path.exists(ccp.CERT_USAGE_LOG):
return []
rows = []
with open(ccp.CERT_USAGE_LOG, "r", encoding="utf-8") as f:
for line in f:
line = line.strip()
if not line:
continue
try:
rows.append(json.loads(line))
except Exception:
continue
return rows
def main():
rows = load_rows()
scanned = 0
changed = 0
skipped = 0
errors = 0
print(f"[OTS_WORKER] rows_total={len(rows)}")
for row in rows:
try:
if str(row.get("cert_type", "")).strip() != "blockchain":
continue
cert_id = str(row.get("cert_id", "") or "").strip()
status = str(row.get("blockchain_status", "") or "").strip() or "pending"
ots_path = str(row.get("ots_path", "") or "").strip()
if not ots_path or not os.path.exists(ots_path):
skipped += 1
print(f"[OTS_WORKER] skip cert_id={cert_id or '-'} reason=no_ots")
continue
before = {
"blockchain_status": row.get("blockchain_status"),
"btc_txid": row.get("btc_txid"),
"btc_block_height": row.get("btc_block_height"),
"anchored_at": row.get("anchored_at"),
"confirmed_at": row.get("confirmed_at"),
"ots_last_upgrade_at": row.get("ots_last_upgrade_at"),
}
scanned += 1
updated = ccp._ots_refresh_row(row)
after = {
"blockchain_status": updated.get("blockchain_status"),
"btc_txid": updated.get("btc_txid"),
"btc_block_height": updated.get("btc_block_height"),
"anchored_at": updated.get("anchored_at"),
"confirmed_at": updated.get("confirmed_at"),
"ots_last_upgrade_at": updated.get("ots_last_upgrade_at"),
}
if before != after:
changed += 1
print(
f"[OTS_WORKER] updated cert_id={cert_id or '-'} "
f"status={before.get('blockchain_status')}->{after.get('blockchain_status')} "
f"txid={after.get('btc_txid') or '-'} "
f"block={after.get('btc_block_height')}"
)
else:
print(
f"[OTS_WORKER] checked cert_id={cert_id or '-'} "
f"status={status} txid={after.get('btc_txid') or '-'} "
f"block={after.get('btc_block_height')}"
)
except Exception as e:
errors += 1
print(f"[OTS_WORKER] error cert_id={row.get('cert_id','-')} err={e}")
traceback.print_exc()
print(
f"[OTS_WORKER] done scanned={scanned} changed={changed} "
f"skipped={skipped} errors={errors}"
)
if __name__ == "__main__":
main()