Browse Source

RPC: pools: Add "Message" to show last client.show_message received over stratum

Luke Dashjr 13 years ago
parent
commit
fd483c3f62
4 changed files with 16 additions and 8 deletions
  1. 8 7
      README.RPC
  2. 2 0
      api.c
  3. 1 0
      miner.h
  4. 5 1
      util.c

+ 8 - 7
README.RPC

@@ -411,13 +411,14 @@ Feature Changelog for external applications using the API:
 API V1.24b
 API V1.24b
 
 
 Modified API commands:
 Modified API commands:
- 'cpustatus' - Added 'ProcID'
- 'gpustatus' - Added 'ProcID'
- 'pgastatus' - Added 'ProcID'
- 'devstatus' - Added 'ProcID'
- 'notify' - Added 'ProcID'
- 'devdetails' - Added 'ProcID'
- 'devdetail' - Added 'Name', 'ID', and 'ProcID'
+ 'cpustatus' - add 'ProcID'
+ 'gpustatus' - add 'ProcID'
+ 'pgastatus' - add 'ProcID'
+ 'devstatus' - add 'ProcID'
+ 'notify' - add 'ProcID'
+ 'devdetails' - add 'ProcID'
+ 'devdetail' - add 'Name', 'ID', and 'ProcID'
+ 'pools' - add 'Message'
 
 
 Pretty much updated every method returning 'Name' and 'ID' to also return
 Pretty much updated every method returning 'Name' and 'ID' to also return
 'ProcID'. This is a number starting with 0 for 'a', 1 for 'b', etc.
 'ProcID'. This is a number starting with 0 for 'a', 1 for 'b', etc.

+ 2 - 0
api.c

@@ -1915,6 +1915,8 @@ static void poolstatus(struct io_data *io_data, __maybe_unused SOCKETTYPE c, __m
 		else
 		else
 			root = api_add_const(root, "Stratum URL", BLANK, false);
 			root = api_add_const(root, "Stratum URL", BLANK, false);
 		root = api_add_uint64(root, "Best Share", &(pool->best_diff), true);
 		root = api_add_uint64(root, "Best Share", &(pool->best_diff), true);
+		if (pool->admin_msg)
+			root = api_add_escape(root, "Message", pool->admin_msg, true);
 
 
 		root = print_data(root, buf, isjson, isjson && (i > 0));
 		root = print_data(root, buf, isjson, isjson && (i > 0));
 		io_add(io_data, buf);
 		io_add(io_data, buf);

+ 1 - 0
miner.h

@@ -1053,6 +1053,7 @@ struct pool {
 	struct stratum_work swork;
 	struct stratum_work swork;
 	pthread_t stratum_thread;
 	pthread_t stratum_thread;
 	pthread_mutex_t stratum_lock;
 	pthread_mutex_t stratum_lock;
+	char *admin_msg;
 
 
 	pthread_mutex_t last_work_lock;
 	pthread_mutex_t last_work_lock;
 	struct work *last_work_copy;
 	struct work *last_work_copy;

+ 5 - 1
util.c

@@ -1463,10 +1463,14 @@ static bool stratum_show_message(struct pool *pool, json_t *val, json_t *params)
 {
 {
 	char s[RBUFSIZE], *idstr;
 	char s[RBUFSIZE], *idstr;
 	json_t *id = json_object_get(val, "id");
 	json_t *id = json_object_get(val, "id");
-	const char *msg = __json_array_string(params, 0);
+	char *msg = json_array_string(params, 0);
 	
 	
 	if (likely(msg))
 	if (likely(msg))
+	{
+		free(pool->admin_msg);
+		pool->admin_msg = msg;
 		applog(LOG_NOTICE, "Message from pool %u: %s", pool->pool_no, msg);
 		applog(LOG_NOTICE, "Message from pool %u: %s", pool->pool_no, msg);
+	}
 	
 	
 	if (!(id && !json_is_null(id)))
 	if (!(id && !json_is_null(id)))
 		return true;
 		return true;