Browse Source

RPC: Accept an additional argument for "addpool" to indicate mining goal by name

Luke Dashjr 11 years ago
parent
commit
2efcc907c8
4 changed files with 26 additions and 9 deletions
  1. 10 2
      README.RPC
  2. 12 4
      api.c
  3. 2 2
      miner.c
  4. 2 1
      miner.h

+ 10 - 2
README.RPC

@@ -213,12 +213,12 @@ The list of requests - a (*) means it requires privileged access - and replies:
                               stating the results of enabling pool N
                               The Msg includes the pool URL
 
- addpool|URL,USR,PASS (*)
+ addpool|URL,USR,PASS[,GOAL] (*)
                none           There is no reply section just the STATUS section
                               stating the results of attempting to add pool N
                               The Msg includes the pool URL
                               Use '\\' to get a '\' and '\,' to include a comma
-                              inside URL, USR or PASS
+                              inside URL, USR, PASS, or GOAL
 
  poolpriority|N,... (*)
                none           There is no reply section just the STATUS section
@@ -449,6 +449,14 @@ https://www.npmjs.org/package/miner-rpc
 Feature Changelog for external applications using the API:
 
 
+API V3.3
+
+Modified API command:
+ 'addpool' - accept an additional argument to indicate mining goal by name
+ 'coin' - return multiple elements, when there are multiple mining goals defined
+
+---------
+
 API V3.2 (BFGMiner v4.1.0)
 
 Modified API command:

+ 12 - 4
api.c

@@ -2365,7 +2365,7 @@ static void copyadvanceafter(char ch, char **param, char **buf)
 	*(dst_b++) = '\0';
 }
 
-static bool pooldetails(char *param, char **url, char **user, char **pass)
+static bool pooldetails(char *param, char **url, char **user, char **pass, char **goalname)
 {
 	char *ptr, *buf;
 
@@ -2393,6 +2393,12 @@ static bool pooldetails(char *param, char **url, char **user, char **pass)
 
 	// copy pass
 	copyadvanceafter(',', &param, &buf);
+	
+	if (*param)
+		*goalname = buf;
+	
+	// copy goalname
+	copyadvanceafter(',', &param, &buf);
 
 	return true;
 
@@ -2403,7 +2409,7 @@ exitsama:
 
 static void addpool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 {
-	char *url, *user, *pass;
+	char *url, *user, *pass, *goalname = "default";
 	struct pool *pool;
 	char *ptr;
 
@@ -2412,7 +2418,8 @@ static void addpool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *
 		return;
 	}
 
-	if (!pooldetails(param, &url, &user, &pass)) {
+	if (!pooldetails(param, &url, &user, &pass, &goalname))
+	{
 		ptr = escape_string(param, isjson);
 		message(io_data, MSG_INVPDP, 0, ptr, isjson);
 		if (ptr != param)
@@ -2421,7 +2428,8 @@ static void addpool(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *
 		return;
 	}
 
-	pool = add_pool();
+	struct mining_goal_info * const goal = get_mining_goal(goalname);
+	pool = add_pool2(goal);
 	detect_stratum(pool, url);
 	add_pool_details(pool, true, url, user, pass);
 

+ 2 - 2
miner.c

@@ -1104,7 +1104,7 @@ void adjust_quota_gcd(void)
 }
 
 /* Return value is ignored if not called from add_pool_details */
-struct pool *add_pool(void)
+struct pool *add_pool2(struct mining_goal_info * const goal)
 {
 	struct pool *pool;
 
@@ -1121,7 +1121,7 @@ struct pool *add_pool(void)
 	mutex_init(&pool->stratum_lock);
 	timer_unset(&pool->swork.tv_transparency);
 	pool->swork.pool = pool;
-	pool->goal = get_mining_goal("default");
+	pool->goal = goal;
 
 	pool->idle = true;
 	/* Make sure the pool doesn't think we've been idle since time 0 */

+ 2 - 1
miner.h

@@ -1096,7 +1096,8 @@ extern void print_summary(void);
 extern struct mining_goal_info *get_mining_goal(const char *name);
 extern void mining_goal_reset(struct mining_goal_info * const goal);
 extern void adjust_quota_gcd(void);
-extern struct pool *add_pool(void);
+extern struct pool *add_pool2(struct mining_goal_info *);
+#define add_pool()  add_pool2(get_mining_goal("default"))
 extern bool add_pool_details(struct pool *pool, bool live, char *url, char *user, char *pass);
 
 #define MAX_GPUDEVICES 16