From cb01a16af801425cf4921720e70a007ddd63f227 Mon Sep 17 00:00:00 2001 From: satoshi Date: Mon, 11 May 2026 02:18:48 +0300 Subject: [PATCH] Add reset-latency StartOS action Calls POST /api/admin/reset-latency to zero the block-update latency counters. Available while the service is running, no warning needed. --- manifest.yaml | 8 +++++++ scripts/procedures/actions.ts | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/manifest.yaml b/manifest.yaml index 9883a5b..38f5efd 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -166,6 +166,14 @@ actions: - stopped implementation: type: script + reset-latency: + name: "Reset Block Latency" + description: "Zeroes the block-update latency counters (avg, last, wasted work, block count). Use this after tuning ZMQ or ckpool to start fresh measurements." + warning: ~ + allowed-statuses: + - running + implementation: + type: script migrations: from: diff --git a/scripts/procedures/actions.ts b/scripts/procedures/actions.ts index 47b3733..fb8f484 100644 --- a/scripts/procedures/actions.ts +++ b/scripts/procedures/actions.ts @@ -249,6 +249,46 @@ export const action: T.ExpectedExports.action = { }; }, + // ── Reset block latency ───────────────────────────────────────────────────── + "reset-latency": async (effects) => { + try { + const res = await effects.fetch(`${API_BASE}/api/admin/reset-latency`, { + method: "POST", + }); + if (!res.ok) { + const body = await res.text(); + return { + result: { + version: "0", + message: "Failed to reset latency stats", + value: `API returned ${res.status}: ${body}`, + copyable: false, + qr: false, + }, + }; + } + } catch (e) { + return { + result: { + version: "0", + message: "Failed — API unreachable", + value: `Could not reach kamado-api: ${(e as Error).message}`, + copyable: false, + qr: false, + }, + }; + } + return { + result: { + version: "0", + message: "Block latency stats reset to zero", + value: "All latency counters (count, avg, last, wasted work) have been cleared.\nNew measurements will accumulate from the next block.", + copyable: false, + qr: false, + }, + }; + }, + // ── Regenerate TLS certificate ────────────────────────────────────────────── "regen-tls-cert": async (effects) => { const VOLUME = "main";