Browse Source

Make ckpool built without ckdb support imply standalone and remove ckdb options when build support is disabled

master
Con Kolivas 10 years ago
parent
commit
55ff1389ee
  1. 3
      README
  2. 1
      configure.ac
  3. 19
      src/ckpool.c
  4. 6
      src/ckpool.h
  5. 8
      src/stratifier.c

3
README

@ -138,6 +138,7 @@ ckpool supports the following options:
-A Standalone mode tells ckpool not to try to communicate with ckdb or log any -A Standalone mode tells ckpool not to try to communicate with ckdb or log any
ckdb requests in the rotating ckdb logs it would otherwise store. All users ckdb requests in the rotating ckdb logs it would otherwise store. All users
are automatically accepted without any attempt to authorise users in any way. are automatically accepted without any attempt to authorise users in any way.
This option is explicitly enabled when built without ckdb support.
-c <CONFIG> tells ckpool to override its default configuration filename and -c <CONFIG> tells ckpool to override its default configuration filename and
load the specified one. If -c is not specified, ckpool looks for ckpool.conf load the specified one. If -c is not specified, ckpool looks for ckpool.conf
@ -145,6 +146,7 @@ whereas in proxy or passthrough modes it will look for ckproxy.conf
-d <CKDB-NAME> tells ckpool what the name of the ckdb process is that it should -d <CKDB-NAME> tells ckpool what the name of the ckdb process is that it should
speak to, otherwise it will look for ckdb. speak to, otherwise it will look for ckdb.
This option does not exist when built without ckdb support.
-g <GROUP> will start ckpool as the group ID specified. -g <GROUP> will start ckpool as the group ID specified.
@ -179,6 +181,7 @@ it to scale to large hashrates. Standalone mode is Optional.
-S <CKDB-SOCKDIR> tells ckpool which directory to look for the ckdb socket to -S <CKDB-SOCKDIR> tells ckpool which directory to look for the ckdb socket to
talk to. talk to.
This option does not exist when built without ckdb support.
-s <SOCKDIR> tells ckpool which directory to place its own communication -s <SOCKDIR> tells ckpool which directory to place its own communication
sockets (/tmp by default) sockets (/tmp by default)

1
configure.ac

@ -59,6 +59,7 @@ AC_ARG_WITH([ckdb],
if test "x$ckdb" != "xno"; then if test "x$ckdb" != "xno"; then
AC_CHECK_LIB([pq], [main],[PQ=-lpq],echo "Error: Required library libpq-dev AC_CHECK_LIB([pq], [main],[PQ=-lpq],echo "Error: Required library libpq-dev
not found. Install it or disable postgresql support with --without-ckdb" && exit 1) not found. Install it or disable postgresql support with --without-ckdb" && exit 1)
AC_DEFINE([USE_CKDB], [1], [Defined to 1 if ckdb support required])
PQ_LIBS="-lpq" PQ_LIBS="-lpq"
else else
PQ_LIBS="" PQ_LIBS=""

19
src/ckpool.c

@ -1058,6 +1058,7 @@ static void *watchdog(void *arg)
return NULL; return NULL;
} }
#ifdef USE_CKDB
static struct option long_options[] = { static struct option long_options[] = {
{"standalone", no_argument, 0, 'A'}, {"standalone", no_argument, 0, 'A'},
{"config", required_argument, 0, 'c'}, {"config", required_argument, 0, 'c'},
@ -1075,6 +1076,22 @@ static struct option long_options[] = {
{"sockdir", required_argument, 0, 's'}, {"sockdir", required_argument, 0, 's'},
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
#else
static struct option long_options[] = {
{"config", required_argument, 0, 'c'},
{"group", required_argument, 0, 'g'},
{"handover", no_argument, 0, 'H'},
{"help", no_argument, 0, 'h'},
{"killold", no_argument, 0, 'k'},
{"log-shares", no_argument, 0, 'L'},
{"loglevel", required_argument, 0, 'l'},
{"name", required_argument, 0, 'n'},
{"passthrough", no_argument, 0, 'P'},
{"proxy", no_argument, 0, 'p'},
{"sockdir", required_argument, 0, 's'},
{0, 0, 0, 0}
};
#endif
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
@ -1193,7 +1210,7 @@ int main(int argc, char **argv)
} }
trail_slash(&ckp.socket_dir); trail_slash(&ckp.socket_dir);
if (!ckp.standalone) { if (!CKP_STANDALONE(&ckp)) {
if (!ckp.ckdb_name) if (!ckp.ckdb_name)
ckp.ckdb_name = "ckdb"; ckp.ckdb_name = "ckdb";
if (!ckp.ckdb_sockdir) { if (!ckp.ckdb_sockdir) {

6
src/ckpool.h

@ -171,6 +171,12 @@ struct ckpool_instance {
server_instance_t *btcdbackup; server_instance_t *btcdbackup;
}; };
#ifdef USE_CKDB
#define CKP_STANDALONE(CKP) ((CKP)->standalone == true)
#else
#define CKP_STANDALONE(CKP) (true)
#endif
ckmsgq_t *create_ckmsgq(ckpool_t *ckp, const char *name, const void *func); ckmsgq_t *create_ckmsgq(ckpool_t *ckp, const char *name, const void *func);
void ckmsgq_add(ckmsgq_t *ckmsgq, void *data); void ckmsgq_add(ckmsgq_t *ckmsgq, void *data);
bool ckmsgq_empty(ckmsgq_t *ckmsgq); bool ckmsgq_empty(ckmsgq_t *ckmsgq);

8
src/stratifier.c

@ -539,7 +539,7 @@ static void _ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val, const char
fflush(stdout); fflush(stdout);
} }
if (ckp->standalone) if (CKP_STANDALONE(ckp))
return json_decref(val); return json_decref(val);
json_msg = ckdb_msg(ckp, val, idtype); json_msg = ckdb_msg(ckp, val, idtype);
@ -1683,7 +1683,7 @@ static json_t *parse_authorise(stratum_instance_t *client, json_t *params_val, j
LOGNOTICE("Authorised client %ld worker %s as user %s", client->id, buf, LOGNOTICE("Authorised client %ld worker %s as user %s", client->id, buf,
user_instance->username); user_instance->username);
client->workername = strdup(buf); client->workername = strdup(buf);
if (client->ckp->standalone) if (CKP_STANDALONE(client->ckp))
ret = true; ret = true;
else { else {
*errnum = send_recv_auth(client); *errnum = send_recv_auth(client);
@ -2203,7 +2203,7 @@ out_unlock:
json_set_int(val, "workinfoid", id); json_set_int(val, "workinfoid", id);
json_set_int(val, "clientid", client->id); json_set_int(val, "clientid", client->id);
json_set_string(val, "enonce1", client->enonce1); json_set_string(val, "enonce1", client->enonce1);
if (!ckp->standalone) if (!CKP_STANDALONE(ckp))
json_set_string(val, "secondaryuserid", user_instance->secondaryuserid); json_set_string(val, "secondaryuserid", user_instance->secondaryuserid);
json_set_string(val, "nonce2", nonce2); json_set_string(val, "nonce2", nonce2);
json_set_string(val, "nonce", nonce); json_set_string(val, "nonce", nonce);
@ -3197,7 +3197,7 @@ int stratifier(proc_instance_t *pi)
sauthq = create_ckmsgq(ckp, "authoriser", &sauth_process); sauthq = create_ckmsgq(ckp, "authoriser", &sauth_process);
ckdbq = create_ckmsgq(ckp, "ckdbqueue", &ckdbq_process); ckdbq = create_ckmsgq(ckp, "ckdbqueue", &ckdbq_process);
stxnq = create_ckmsgq(ckp, "stxnq", &send_transactions); stxnq = create_ckmsgq(ckp, "stxnq", &send_transactions);
if (!ckp->standalone) if (!CKP_STANDALONE(ckp))
create_pthread(&pth_heartbeat, ckdb_heartbeat, ckp); create_pthread(&pth_heartbeat, ckdb_heartbeat, ckp);
cklock_init(&workbase_lock); cklock_init(&workbase_lock);

Loading…
Cancel
Save