diff --git a/README b/README index 17f428a7..15d47c46 100644 --- a/README +++ b/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 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. +This option is explicitly enabled when built without ckdb support. -c tells ckpool to override its default configuration filename and 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 tells ckpool what the name of the ckdb process is that it should speak to, otherwise it will look for ckdb. +This option does not exist when built without ckdb support. -g will start ckpool as the group ID specified. @@ -179,6 +181,7 @@ it to scale to large hashrates. Standalone mode is Optional. -S tells ckpool which directory to look for the ckdb socket to talk to. +This option does not exist when built without ckdb support. -s tells ckpool which directory to place its own communication sockets (/tmp by default) diff --git a/configure.ac b/configure.ac index 3f646444..218a2392 100644 --- a/configure.ac +++ b/configure.ac @@ -59,6 +59,7 @@ AC_ARG_WITH([ckdb], if test "x$ckdb" != "xno"; then 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) + AC_DEFINE([USE_CKDB], [1], [Defined to 1 if ckdb support required]) PQ_LIBS="-lpq" else PQ_LIBS="" diff --git a/src/ckpool.c b/src/ckpool.c index 6c2b02ec..dee10716 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -1058,6 +1058,7 @@ static void *watchdog(void *arg) return NULL; } +#ifdef USE_CKDB static struct option long_options[] = { {"standalone", no_argument, 0, 'A'}, {"config", required_argument, 0, 'c'}, @@ -1075,6 +1076,22 @@ static struct option long_options[] = { {"sockdir", required_argument, 0, 's'}, {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) { @@ -1193,7 +1210,7 @@ int main(int argc, char **argv) } trail_slash(&ckp.socket_dir); - if (!ckp.standalone) { + if (!CKP_STANDALONE(&ckp)) { if (!ckp.ckdb_name) ckp.ckdb_name = "ckdb"; if (!ckp.ckdb_sockdir) { diff --git a/src/ckpool.h b/src/ckpool.h index e7715d47..a29798d3 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -171,6 +171,12 @@ struct ckpool_instance { 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); void ckmsgq_add(ckmsgq_t *ckmsgq, void *data); bool ckmsgq_empty(ckmsgq_t *ckmsgq); diff --git a/src/stratifier.c b/src/stratifier.c index f473c2a6..55b84346 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -539,7 +539,7 @@ static void _ckdbq_add(ckpool_t *ckp, const int idtype, json_t *val, const char fflush(stdout); } - if (ckp->standalone) + if (CKP_STANDALONE(ckp)) return json_decref(val); 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, user_instance->username); client->workername = strdup(buf); - if (client->ckp->standalone) + if (CKP_STANDALONE(client->ckp)) ret = true; else { *errnum = send_recv_auth(client); @@ -2203,7 +2203,7 @@ out_unlock: json_set_int(val, "workinfoid", id); json_set_int(val, "clientid", client->id); 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, "nonce2", nonce2); json_set_string(val, "nonce", nonce); @@ -3197,7 +3197,7 @@ int stratifier(proc_instance_t *pi) sauthq = create_ckmsgq(ckp, "authoriser", &sauth_process); ckdbq = create_ckmsgq(ckp, "ckdbqueue", &ckdbq_process); stxnq = create_ckmsgq(ckp, "stxnq", &send_transactions); - if (!ckp->standalone) + if (!CKP_STANDALONE(ckp)) create_pthread(&pth_heartbeat, ckdb_heartbeat, ckp); cklock_init(&workbase_lock);