ckpool: expose bestever in runtime socket JSON

Upstream ckpool tracks user/worker best_ever across block solves but
only emits it in the on-disk users.json/workers.json persistence files,
not in the runtime socket API (userinfo() / workerinfo() in
stratifier.c). Consumers that poll the socket — like kamado-api — see
bestdiff reset to zero on every block solve via reset_bestshares()
with no all-time field to fall back on. That is the "best share stuck
at zero after a block" UX we want to fix in Kamado.

0001-expose-bestever-in-runtime-json.patch adds bestever to the two
JSON_CPACK calls so the UI can show current-round and all-time side
by side. No behavioral change, no impact on share validation or block
handling. Candidate for upstreaming.

Also surfaces BestEver in api/internal/ckpool types (User, Worker).
Gracefully degrades to 0 on an unpatched ckpool.
This commit is contained in:
satoshi
2026-04-13 03:03:21 +03:00
parent 0a40b8f84f
commit 36c08647e2
3 changed files with 62 additions and 4 deletions
+23 -2
View File
@@ -9,8 +9,29 @@ Patches are applied in alphabetical order by filename. Use a numeric prefix to e
## Current state
**No patches are applied.** The pinned upstream commit (`cfb0f83b`, tagged
as version 1.0) already includes every fix that Bassin issue #29 asked to
One Kamado patch is applied on top of the pinned upstream commit:
| Patch | What it does |
| --------------------------------------------- | -------------------------------------------------------------------------------------- |
| `0001-expose-bestever-in-runtime-json.patch` | Adds `bestever` field to the `users` / `workers` runtime socket JSON |
### Why 0001 matters
Upstream tracks `best_ever` internally in `user_instance_t` / `worker_instance_t`
and zeroes `best_diff` on every block solve via `reset_bestshares()`. That
is correct: `bestdiff` is "best share in the current round". But the runtime
socket API (`userinfo()` / `workerinfo()` in `stratifier.c`) only emits
`bestdiff`, so any consumer that talks to the socket — like `kamado-api`
sees the best share reset to 0 after every block and has no all-time field
to fall back on. The on-disk `users.json` / `workers.json` persistence files
do include `bestever`, but polling those is racy and lags the socket.
This patch adds `bestever` to the runtime JSON so the UI can show both
"this round" and "all-time" best share side by side. No behavioral change
to share validation or block handling. Candidate for upstreaming.
Beyond this patch, the pinned upstream commit (`cfb0f83b`, tagged as
version 1.0) already includes every fix that Bassin issue #29 asked to
backport, plus several improvements:
| Upstream commit | What it fixes |