mirror of
https://github.com/GOSTSec/sgminer
synced 2025-03-13 06:01:03 +00:00
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.
This commit is contained in:
parent
50a792f2cd
commit
92b7770212
@ -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;
|
||||
}
|
||||
|
@ -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
Normal file
26
doc/configuration.md
Normal file
@ -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
2
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;
|
||||
|
18
sgminer.c
18
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"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user