Browse Source

config: add `--algorithm` option and documentation.

Doc in `doc/configuration.md` (has to be started sometime, no?).

Configuration function has to be lamely-named set_algo(), because
set_algorithm() is already declared in algorithm.h (prevent namespace
conflict).

algorithm has to be added as global variable due to the way the
callback is done (by CCAN/opt, which in itself is nice).

This can be cleaned up significantly by (at least) introducing a
global configuration struct, but there is no reason to do it now
just for this - better a wholesale manana.
build-mingw
Noel Maersk 11 years ago
parent
commit
92b7770212
  1. 4
      algorithm.c
  2. 4
      algorithm.h
  3. 26
      doc/configuration.md
  4. 2
      miner.h
  5. 18
      sgminer.c

4
algorithm.c

@ -17,7 +17,7 @@ typedef struct algorithm_t { @@ -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) { @@ -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;
}

4
algorithm.h

@ -9,9 +9,9 @@ @@ -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 */

26
doc/configuration.md

@ -0,0 +1,26 @@ @@ -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.

2
miner.h

@ -1018,6 +1018,8 @@ extern bool fulltest(const unsigned char *hash, const unsigned char *target); @@ -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;

18
sgminer.c

@ -54,6 +54,8 @@ char *curly = ":D"; @@ -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; @@ -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() @@ -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) @@ -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[] = { @@ -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"),

Loading…
Cancel
Save