1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-11 07:17:58 +00:00
sgminer/algorithm.c
Noel Maersk 92b7770212 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.
2014-03-07 02:27:00 +02:00

34 lines
950 B
C

/*
* Copyright 2014 sgminer developers
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version. See COPYING for more details.
*/
#include "algorithm.h"
#include <inttypes.h>
#include <string.h>
typedef struct algorithm_t {
char name[20]; /* Human-readable identifier */
uint8_t nfactor; /* N factor (CPU/Memory tradeoff parameter) */
} algorithm_t;
void set_algorithm(algorithm_t* algo, const char* newname) {
strncpy(algo->name, newname, sizeof(algo->name));
algo->name[sizeof(algo->name) - 1] = '\0';
if (strcmp(algo->name, "adaptive-nfactor") == 0) {
algo->nfactor = 11;
} else {
algo->nfactor = 10;
}
}
void set_algorithm_nfactor(algorithm_t* algo, const uint8_t nfactor) {
algo->nfactor = nfactor;
}