Browse Source

config: fix -c param (json file)

master
Tanguy Pruvot 10 years ago
parent
commit
88c8fa2973
  1. 23
      cpu-miner.c
  2. 11
      example-cfg.json

23
cpu-miner.c

@ -205,7 +205,7 @@ int opt_timeout = 270; @@ -205,7 +205,7 @@ int opt_timeout = 270;
static int opt_scantime = 5;
static json_t *opt_config;
static const bool opt_time = true;
static sha256_algos opt_algo = ALGO_HEAVY;
static sha256_algos opt_algo = ALGO_X11;
int opt_n_threads = 0;
static double opt_difficulty = 1; // CH
bool opt_trust_pool = false;
@ -336,13 +336,13 @@ static struct option const options[] = { @@ -336,13 +336,13 @@ static struct option const options[] = {
{ "background", 0, NULL, 'B' },
#endif
{ "benchmark", 0, NULL, 1005 },
{ "cputest", 0, NULL, 1006 },
{ "cert", 1, NULL, 1001 },
{ "config", 1, NULL, 'c' },
{ "no-color", 0, NULL, 1002 },
{ "cputest", 0, NULL, 1006 },
{ "debug", 0, NULL, 'D' },
{ "help", 0, NULL, 'h' },
{ "intensity", 1, NULL, 'i' },
{ "no-color", 0, NULL, 1002 },
{ "no-longpoll", 0, NULL, 1003 },
{ "no-stratum", 0, NULL, 1007 },
{ "pass", 1, NULL, 'p' },
@ -1827,6 +1827,9 @@ static void parse_arg (int key, char *arg) @@ -1827,6 +1827,9 @@ static void parse_arg (int key, char *arg)
use_colors = false;
}
/**
* Parse json config file
*/
static void parse_config(void)
{
int i;
@ -1836,6 +1839,7 @@ static void parse_config(void) @@ -1836,6 +1839,7 @@ static void parse_config(void)
return;
for (i = 0; i < ARRAY_SIZE(options); i++) {
if (!options[i].name)
break;
if (!strcmp(options[i].name, "config"))
@ -1849,6 +1853,7 @@ static void parse_config(void) @@ -1849,6 +1853,7 @@ static void parse_config(void)
char *s = strdup(json_string_value(val));
if (!s)
break;
// applog(LOG_DEBUG, "%s -%c %s", options[i].name, options[i].val, s);
parse_arg(options[i].val, s);
free(s);
} else if (!options[i].has_arg && json_is_true(val))
@ -1857,11 +1862,6 @@ static void parse_config(void) @@ -1857,11 +1862,6 @@ static void parse_config(void)
applog(LOG_ERR, "JSON option %s invalid",
options[i].name);
}
if (opt_algo == ALGO_HEAVY && opt_vote == 9999) {
fprintf(stderr, "Heavycoin hash requires block reward vote parameter (see --vote)\n");
show_usage_and_exit(1);
}
}
static void parse_cmdline(int argc, char *argv[])
@ -1885,13 +1885,13 @@ static void parse_cmdline(int argc, char *argv[]) @@ -1885,13 +1885,13 @@ static void parse_cmdline(int argc, char *argv[])
show_usage_and_exit(1);
}
parse_config();
if (opt_algo == ALGO_HEAVY && opt_vote == 9999) {
fprintf(stderr, "%s: Heavycoin hash requires block reward vote parameter (see --vote)\n",
argv[0]);
show_usage_and_exit(1);
}
parse_config();
}
#ifndef WIN32
@ -1954,12 +1954,11 @@ int main(int argc, char *argv[]) @@ -1954,12 +1954,11 @@ int main(int argc, char *argv[])
pthread_mutex_init(&applog_lock, NULL);
num_processors = cuda_num_devices();
cuda_devicenames();
/* parse command line */
parse_cmdline(argc, argv);
cuda_devicenames();
if (!opt_benchmark && !rpc_url) {
fprintf(stderr, "%s: no URL supplied\n", argv[0]);
show_usage_and_exit(1);

11
example-cfg.json

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
{
"_comment" : "todo: support /* comments */",
"algo" : "blake",
"_quiet" : true,
"url" : "stratum+tcp://www.hashharder.com:9585",
"user" : "NaEcVrdzoCWHUYXb7X8QoafoKS9UV69Yk4",
"pass" : "ccminer"
}
Loading…
Cancel
Save