Add block-update latency tracking, raw share counters, and shares bar UI

Log ZMQ→mining.notify latency in ckpool (patch 0005), expose a raw
reject counter (patch 0006), and surface both in the dashboard:

- Block latency card shows avg/last ms, wasted work, and block count
- SharesBar component shows session + all-time accepted/rejected with
  a Demon Slayer flame-slash animation on new shares
- Miners card info moved to MinersTable section header
- Latency stats and share counts persist across restarts via kv store
- Removed misleading pool-wide share stats from per-worker/user pages
  (ckpool doesn't expose per-user raw counts)
This commit is contained in:
satoshi
2026-05-11 02:12:16 +03:00
parent e622f1a81a
commit 6acff6280f
14 changed files with 555 additions and 18 deletions
+33
View File
@@ -80,6 +80,39 @@ func (a *Aggregator) IngestAttemptEvents(ctx context.Context, events <-chan logm
}
}
// IngestLatencyEvents reads block-update latency events from the tailer
// and accumulates stats for the dashboard. Stats are persisted to the
// kv store so they survive restarts.
func (a *Aggregator) IngestLatencyEvents(ctx context.Context, events <-chan logmon.LatencyEvent) {
for {
select {
case <-ctx.Done():
return
case ev, ok := <-events:
if !ok {
return
}
a.mu.Lock()
a.latencyCount++
a.latencySumMs += ev.LatencyMs
a.latencyLastMs = ev.LatencyMs
// Wasted hashes = latency in seconds × current 5m hashrate.
hs5m := a.snap.HashrateHs5m
a.staleWorkHashes += (float64(ev.LatencyMs) / 1000.0) * hs5m
count, sum, last, stale := a.latencyCount, a.latencySumMs, a.latencyLastMs, a.staleWorkHashes
a.mu.Unlock()
a.Log.Info("logmon: block update latency", "ms", ev.LatencyMs, "count", count)
// Blocks are infrequent (~10min); persist every event.
if a.Store != nil {
_ = a.Store.SetKV(kvLatencyCount, strconv.FormatInt(count, 10))
_ = a.Store.SetKV(kvLatencySumMs, strconv.FormatInt(sum, 10))
_ = a.Store.SetKV(kvLatencyLastMs, strconv.FormatInt(last, 10))
_ = a.Store.SetKV(kvStaleWorkHashes, strconv.FormatFloat(stale, 'f', -1, 64))
}
}
}
}
// IngestBlockEvents reads block events from the tailer and appends them
// to the snapshot's block history. Runs until ctx is cancelled.
func (a *Aggregator) IngestBlockEvents(ctx context.Context, events <-chan logmon.BlockEvent) {