Browse Source

RPC: Add "Coinbase-Sig" to config/setconfig

Luke Dashjr 13 years ago
parent
commit
c89d4ea76d
4 changed files with 24 additions and 6 deletions
  1. 6 4
      API-README
  2. 9 0
      api.c
  3. 8 2
      miner.c
  4. 1 0
      miner.h

+ 6 - 4
API-README

@@ -324,12 +324,13 @@ The list of requests - a (*) means it requires privileged access - and replies a
                               PerDevice=true/false,
                               WorkTime=true/false|
 
- setconfig|name,N (*)
+ setconfig|name,value (*)
                none           There is no reply section just the STATUS section
-                              stating the results of setting 'name' to N
+                              stating the results of setting 'name'
                               The valid values for name are currently:
-                              queue, scantime, expiry
-                              N is an integer in the range 0 to 9999
+                              queue, scantime, expiry (integer in the range
+                                                       0 to 9999)
+                              coinbase-sig (string)
 
 When you enable, disable or restart a GPU or PGA, you will also get Thread messages
 in the BFGMiner status window
@@ -401,6 +402,7 @@ Modified API commands:
                'Difficulty Stale', 'Last Share Difficulty'
  'stats' - add 'Work Diff', 'Min Diff', 'Max Diff', 'Min Diff Count',
                'Max Diff Count' to the pool stats
+ 'setconfig|name,value' - add 'Coinbase-Sig' string
 
 ----------
 

+ 9 - 0
api.c

@@ -1323,6 +1323,7 @@ static void minerconfig(__maybe_unused SOCKETTYPE c, __maybe_unused char *param,
 	root = api_add_int(root, "ScanTime", &opt_scantime, false);
 	root = api_add_int(root, "Queue", &opt_queue, false);
 	root = api_add_int(root, "Expiry", &opt_expiry, false);
+	root = api_add_string(root, "Coinbase-Sig", opt_coinbase_sig, true);
 
 	root = print_data(root, buf, isjson);
 	if (isjson)
@@ -2911,6 +2912,14 @@ static void setconfig(__maybe_unused SOCKETTYPE c, char *param, bool isjson, __m
 	}
 
 	*(comma++) = '\0';
+
+	if (strcasecmp(param, "coinbase-sig") == 0) {
+		free(opt_coinbase_sig);
+		opt_coinbase_sig = strdup(comma);
+		strcpy(io_buffer, message(MSG_SETCONFIG, 1, param, isjson));
+		return;
+	}
+
 	value = atoi(comma);
 	if (value < 0 || value > 9999) {
 		strcpy(io_buffer, message(MSG_INVNUM, value, param, isjson));

+ 8 - 2
miner.c

@@ -514,6 +514,12 @@ static char *set_int_1_to_10(const char *arg, int *i)
 	return set_int_range(arg, i, 1, 10);
 }
 
+char *set_strdup(const char *arg, char **p)
+{
+	*p = strdup((char *)arg);
+	return NULL;
+}
+
 #ifdef HAVE_LIBUDEV
 #include <libudev.h>
 #endif
@@ -940,10 +946,10 @@ static struct opt_table opt_config_table[] = {
 #endif
 #if BLKMAKER_VERSION > 0
 	OPT_WITH_ARG("--coinbase-sig",
-		     opt_set_charp, NULL, &opt_coinbase_sig,
+		     set_strdup, NULL, &opt_coinbase_sig,
 		     "Set coinbase signature when possible"),
 	OPT_WITH_ARG("--coinbase|--cbsig|--cb-sig|--cb|--prayer",
-		     opt_set_charp, NULL, &opt_coinbase_sig,
+		     set_strdup, NULL, &opt_coinbase_sig,
 		     opt_hidden),
 #endif
 #ifdef WANT_CPUMINE

+ 1 - 0
miner.h

@@ -633,6 +633,7 @@ static inline void rwlock_init(pthread_rwlock_t *lock)
 struct pool;
 
 extern bool opt_protocol;
+extern char *opt_coinbase_sig;
 extern bool have_longpoll;
 extern char *opt_kernel_path;
 extern char *opt_socks_proxy;