From 03177064643007d6866e7201250bd763c1185a91 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Tue, 11 Nov 2014 20:55:25 +0100 Subject: [PATCH] config: handle ints, reals and false --- README.txt | 3 ++- cpu-miner.c | 18 +++++++++++++++--- example-cfg.json | 4 +++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.txt b/README.txt index caac95d..6f5b0ee 100644 --- a/README.txt +++ b/README.txt @@ -155,11 +155,12 @@ features. >>> RELEASE HISTORY <<< Nov. 11th 2014 v1.4.7 - Average hashrate (based on the 50 last scans) + Average hashrate (based on the 20 last scans) Rewrite blake algo Add the -i (gpu threads/intensity parameter) Add some X11 optimisations based on sp_ commits Fix quark reported hashrate and benchmark mode for some algos + Enhance json config file param (int/float/false) (-c config.json) Update windows prebuilt curl to 7.38.0 Oct. 26th 2014 v1.4.6 diff --git a/cpu-miner.c b/cpu-miner.c index 53edc76..395fedc 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -1853,11 +1853,23 @@ 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)) - parse_arg(options[i].val, ""); + } + else if (options[i].has_arg && json_is_integer(val)) { + char buf[16]; + sprintf(buf, "%d", json_integer_value(val)); + parse_arg(options[i].val, buf); + } + else if (options[i].has_arg && json_is_real(val)) { + char buf[16]; + sprintf(buf, "%f", json_real_value(val)); + parse_arg(options[i].val, buf); + } + else if (!options[i].has_arg) { + if (json_is_true(val)) + parse_arg(options[i].val, ""); + } else applog(LOG_ERR, "JSON option %s invalid", options[i].name); diff --git a/example-cfg.json b/example-cfg.json index 05837dd..f6f848a 100644 --- a/example-cfg.json +++ b/example-cfg.json @@ -2,8 +2,10 @@ "_comment" : "todo: support /* comments */", "algo" : "blake", + "intensity": 19, + "diff": 0.5, - "_quiet" : true, + "quiet" : false, "url" : "stratum+tcp://www.hashharder.com:9585", "user" : "NaEcVrdzoCWHUYXb7X8QoafoKS9UV69Yk4",