diff --git a/api/internal/ckpool/types.go b/api/internal/ckpool/types.go index 0681ff6..d5ab39d 100644 --- a/api/internal/ckpool/types.go +++ b/api/internal/ckpool/types.go @@ -35,12 +35,15 @@ type PoolStats struct { DSPS10080 float64 `json:"dsps10080"` } -// User is one entry in the `users` response. +// User is one entry in the `users` response. BestEver is exposed by the +// Kamado ckpool patch (patches/0001-expose-bestever-in-runtime-json.patch) +// and will be 0 against an unpatched upstream ckpool. type User struct { User string `json:"user"` ID int64 `json:"id"` Workers int `json:"workers"` BestDiff float64 `json:"bestdiff"` + BestEver float64 `json:"bestever"` DSPS1 float64 `json:"dsps1"` DSPS5 float64 `json:"dsps5"` DSPS60 float64 `json:"dsps60"` @@ -53,7 +56,8 @@ type UsersResponse struct { Users []User `json:"users"` } -// Worker is one entry in the `workers` response. +// Worker is one entry in the `workers` response. BestEver requires the +// Kamado ckpool patch; see User above. type Worker struct { User string `json:"user"` Worker string `json:"worker"` @@ -64,6 +68,7 @@ type Worker struct { DSPS1440 float64 `json:"dsps1440"` LastShare int64 `json:"lastshare"` BestDiff float64 `json:"bestdiff"` + BestEver float64 `json:"bestever"` MinDiff float64 `json:"mindiff"` Idle bool `json:"idle"` } diff --git a/ckpool/patches/0001-expose-bestever-in-runtime-json.patch b/ckpool/patches/0001-expose-bestever-in-runtime-json.patch new file mode 100644 index 0000000..77eb5bd --- /dev/null +++ b/ckpool/patches/0001-expose-bestever-in-runtime-json.patch @@ -0,0 +1,32 @@ +diff --git a/src/stratifier.c b/src/stratifier.c +index 8281fa02..c94ca645 100644 +--- a/src/stratifier.c ++++ b/src/stratifier.c +@@ -4007,9 +4007,10 @@ static json_t *userinfo(const user_instance_t *user) + { + json_t *val; + +- JSON_CPACK(val, "{ss,si,si,sf,sf,sf,sf,sf,sf,si}", ++ JSON_CPACK(val, "{ss,si,si,sf,sf,sf,sf,sf,sf,sf,si}", + "user", user->username, "id", user->id, "workers", user->workers, +- "bestdiff", user->best_diff, "dsps1", user->dsps1, "dsps5", user->dsps5, ++ "bestdiff", user->best_diff, "bestever", (double)user->best_ever, ++ "dsps1", user->dsps1, "dsps5", user->dsps5, + "dsps60", user->dsps60, "dsps1440", user->dsps1440, "dsps10080", user->dsps10080, + "lastshare", user->last_share.tv_sec); + return val; +@@ -4128,11 +4129,12 @@ static json_t *workerinfo(const user_instance_t *user, const worker_instance_t * + { + json_t *val; + +- JSON_CPACK(val, "{ss,ss,si,sf,sf,sf,sf,si,sf,si,sb}", ++ JSON_CPACK(val, "{ss,ss,si,sf,sf,sf,sf,si,sf,sf,si,sb}", + "user", user->username, "worker", worker->workername, "id", user->id, + "dsps1", worker->dsps1, "dsps5", worker->dsps5, "dsps60", worker->dsps60, + "dsps1440", worker->dsps1440, "lastshare", worker->last_share.tv_sec, +- "bestdiff", worker->best_diff, "mindiff", worker->mindiff, "idle", worker->idle); ++ "bestdiff", worker->best_diff, "bestever", (double)worker->best_ever, ++ "mindiff", worker->mindiff, "idle", worker->idle); + return val; + } + diff --git a/ckpool/patches/README.md b/ckpool/patches/README.md index c737c72..15ac75f 100644 --- a/ckpool/patches/README.md +++ b/ckpool/patches/README.md @@ -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 |