From 8de767646d659bd1fc2a89ea6aa18ebfda9fce26 Mon Sep 17 00:00:00 2001 From: satoshi Date: Fri, 17 Apr 2026 23:06:49 +0300 Subject: [PATCH] Patch ckpool: enable socket API responses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Upstream ckpool-solo stubs out send_api_response as a no-op, so the stratifier socket accepts commands like poolstats/users/workers but never writes anything back — kamado-api always gets EOF. Replace the stub with a real implementation: serialize the json_t with json_dumps, write via send_unix_msg, and free. The stratum_loop retry label handles socket cleanup. --- .../0002-enable-socket-api-responses.patch | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ckpool/patches/0002-enable-socket-api-responses.patch diff --git a/ckpool/patches/0002-enable-socket-api-responses.patch b/ckpool/patches/0002-enable-socket-api-responses.patch new file mode 100644 index 0000000..0036aa6 --- /dev/null +++ b/ckpool/patches/0002-enable-socket-api-responses.patch @@ -0,0 +1,26 @@ +diff --git a/src/ckpool.h b/src/ckpool.h +index 0921496..58fbc95 100644 +--- a/src/ckpool.h ++++ b/src/ckpool.h +@@ -394,7 +394,20 @@ struct apimsg { + static inline void ckpool_api(ckpool_t __maybe_unused *ckp, apimsg_t __maybe_unused *apimsg) {}; + static inline json_t *json_encode_errormsg(json_error_t __maybe_unused *err_val) { return NULL; }; + static inline json_t *json_errormsg(const char __maybe_unused *fmt, ...) { return NULL; }; +-static inline void send_api_response(json_t __maybe_unused *val, const int __maybe_unused sockd) {}; ++ ++/* Send a JSON value as a length-prefixed unix message so that external ++ * tools (kamado-api) can query live pool/user/worker stats via the ++ * stratifier socket. The caller (stratum_loop retry:) closes sockd. */ ++static inline void send_api_response(json_t *val, const int sockd) ++{ ++ char *response; ++ ++ response = json_dumps(val, JSON_NO_UTF8 | JSON_PRESERVE_ORDER); ++ json_decref(val); ++ if (response) ++ send_unix_msg(sockd, response); ++ free(response); ++} + + /* Subclients have client_ids in the high bits. Returns the value of the parent + * client if one exists. */