diff --git a/algorithm.c b/algorithm.c index f1f61a4b..90f53ddf 100644 --- a/algorithm.c +++ b/algorithm.c @@ -17,7 +17,7 @@ typedef struct algorithm_t { uint8_t nfactor; /* N factor (CPU/Memory tradeoff parameter) */ } algorithm_t; -void set_algorithm(algorithm_t* algo, char* newname) { +void set_algorithm(algorithm_t* algo, const char* newname) { strncpy(algo->name, newname, sizeof(algo->name)); algo->name[sizeof(algo->name) - 1] = '\0'; @@ -28,6 +28,6 @@ void set_algorithm(algorithm_t* algo, char* newname) { } } -void set_algorithm_nfactor(algorithm_t* algo, uint8_t nfactor) { +void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor) { algo->nfactor = nfactor; } diff --git a/algorithm.h b/algorithm.h index 8d89eaef..b0749958 100644 --- a/algorithm.h +++ b/algorithm.h @@ -9,9 +9,9 @@ typedef struct algorithm_t algorithm_t; /* Set default parameters based on name. */ -void set_algorithm(algorithm_t* algo, char* name); +void set_algorithm(algorithm_t* algo, const char* name); /* Set to specific N factor. */ -void set_algorithm_nfactor(algorithm_t* algo, uint8_t nfactor); +void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor); #endif /* ALGORITHM_H */ diff --git a/doc/configuration.md b/doc/configuration.md new file mode 100644 index 00000000..8686d533 --- /dev/null +++ b/doc/configuration.md @@ -0,0 +1,26 @@ +# Configuration and command-line options + +*Work in progress!* + + +## Config-file and CLI options + +### algorithm + +Allows choosing between the few mining algorithms for incompatible +cryptocurrencies. + +Requires a string. + +Currently supported: + +* `adaptive-nfactor` - Vertcoin-style adaptive N-factor scrypt. +N-factor defaults to 11. +* everything else - Litecoin-style static N-factor scrypt. + + +### nfactor + +Overrides the default N-factor scrypt parameter. + +Requires an unsigned integer. diff --git a/miner.h b/miner.h index 589bed5f..81dea7a9 100644 --- a/miner.h +++ b/miner.h @@ -1018,6 +1018,8 @@ extern bool fulltest(const unsigned char *hash, const unsigned char *target); extern int opt_queue; extern int opt_scantime; extern int opt_expiry; + +extern char* opt_algorithm; extern int opt_nfactor; extern cglock_t control_lock; diff --git a/sgminer.c b/sgminer.c index e3301337..6c5c265d 100644 --- a/sgminer.c +++ b/sgminer.c @@ -54,6 +54,8 @@ char *curly = ":D"; #include "adl.h" #include "driver-opencl.h" #include "bench_block.h" + +#include "algorithm.h" #include "scrypt.h" #if defined(unix) || defined(__APPLE__) @@ -92,7 +94,11 @@ int opt_log_interval = 5; int opt_queue = 1; int opt_scantime = 7; int opt_expiry = 28; + +char* opt_algorithm; +algorithm_t* algorithm; int opt_nfactor = 10; + static const bool opt_time = true; unsigned long long global_hashrate; unsigned long global_quota_gcd = 1; @@ -1005,6 +1011,13 @@ static void load_temp_cutoffs() } } +static char *set_algo(const char *arg) +{ + set_algorithm(algorithm, arg); + + return NULL; +} + static char *set_api_allow(const char *arg) { opt_set_charp(arg, &opt_api_allow); @@ -1054,6 +1067,9 @@ static char *set_null(const char __maybe_unused *arg) /* These options are available from config file or commandline */ static struct opt_table opt_config_table[] = { + OPT_WITH_ARG("--algorithm", + set_algo, NULL, NULL, + "Set mining algorithm to most common defaults, default: static"), OPT_WITH_ARG("--api-allow", set_api_allow, NULL, NULL, "Allow API access only to the given list of [G:]IP[/Prefix] addresses[/subnets]"), @@ -1108,7 +1124,7 @@ static struct opt_table opt_config_table[] = { #endif OPT_WITH_ARG("--nfactor", set_int_0_to_9999, opt_show_intval, &opt_nfactor, - "Set scrypt nfactor, default: 10. Currently use 11 for vertcoin!"), + "Set scrypt N-factor parameter, default: 10. Currently use 11 for vertcoin!"), OPT_WITHOUT_ARG("--debug|-D", enable_debug, &opt_debug, "Enable debug output"),