Readiness, Electrum status, audit browsing and logs (B-92, API-37, API-46, API-47, AUD-34, AUD-41, ARC-02, ARC-09, ARC-61, ELC-29, SEC-48)
- GET /health/ready (Electrum connected, header < 1800s, scheduler heartbeat < 30s) is the container healthcheck; the scheduler beats on every tick and draw-wait iteration - GET /admin/electrum and an Electrum indicator in /admin (server, header age, last rotation) - GET /admin/audit-log: before_id, event_type, round_id, user_id, from, to; the panel gets filters - registration writes user_registered in its transaction - the app's own logs also go to stdout; uvicorn trusts X-Forwarded-For from Caddy's fixed address only, so the access log shows the client's IP Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9520c80dcf
commit
575f1a5354
23 files changed
+478
-91
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import time
|
||||
import logging
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
@@ -62,9 +63,16 @@ class RoundScheduler:
|
||||
def __init__(self, session_factory: async_sessionmaker, listener: ElectrumListener):
|
||||
self._session_factory = session_factory
|
||||
self._listener = listener
|
||||
# B-92 (ARC-61): monotonic time of the last tick or draw-wait iteration, read by
|
||||
# /health/ready. The draw wait runs inside a tick and lasts several blocks, so it beats too.
|
||||
self.last_heartbeat: float | None = None
|
||||
|
||||
def heartbeat_age_seconds(self) -> int | None:
|
||||
return None if self.last_heartbeat is None else int(time.monotonic() - self.last_heartbeat)
|
||||
|
||||
async def run(self) -> None:
|
||||
while True:
|
||||
self.last_heartbeat = time.monotonic()
|
||||
try:
|
||||
await self._tick()
|
||||
except asyncio.CancelledError:
|
||||
@@ -409,6 +417,7 @@ class RoundScheduler:
|
||||
reported_hashes: set[str | None] = set()
|
||||
|
||||
while True:
|
||||
self.last_heartbeat = time.monotonic()
|
||||
now = datetime.now(timezone.utc)
|
||||
tip = self._listener.tip_height
|
||||
if tip >= required_tip:
|
||||
|
||||
Reference in new issue
Block a user