From a89e1fb9afc506fcfd32b5928484a96fa91fdb8c Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sat, 3 May 2014 19:36:43 +1000 Subject: [PATCH] Add a stratum message sending function and a welcome message on connecting --- src/stratifier.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/stratifier.c b/src/stratifier.c index 83ac724e..d890847f 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -817,6 +817,15 @@ static void stratum_send_diff(stratum_instance_t *client) stratum_add_send(json_msg, client->id); } +static void stratum_send_message(stratum_instance_t *client, const char *msg) +{ + json_t *json_msg; + + json_msg = json_pack("{sosss[s]}", "id", json_null(), "method", "client.show_message", + "params", msg); + stratum_add_send(json_msg, client->id); +} + static double time_bias(double tdiff, double period) { return 1.0 - 1.0 / exp(tdiff / period); @@ -1205,8 +1214,10 @@ static json_t *gen_json_result(int client_id, json_t *json_msg, json_t *method_v } ck_runlock(&instance_lock); - if (!strncasecmp(method, "mining.authorize", 16)) { + if (!strncasecmp(method, "mining.auth", 11)) { ret = parse_authorize(client, params_val, err_val); + if (ret) + stratum_send_message(client, "Authorised, welcome to ckpool!"); goto out; }