Skip to content

Commit

Permalink
RPC: Accept an additional argument for "addpool" to indicate mining g…
Browse files Browse the repository at this point in the history
…oal by name
  • Loading branch information
luke-jr committed Oct 29, 2014
1 parent 5071e2f commit 2efcc90
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
12 changes: 10 additions & 2 deletions README.RPC
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 12 additions & 4 deletions api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand All @@ -2403,7 +2409,7 @@ static bool pooldetails(char *param, char **url, char **user, char **pass)

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;

Expand All @@ -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)
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2efcc90

Please sign in to comment.