1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-09 22:38:01 +00:00

Made opt_algorithm to simple variable

This commit is contained in:
Elbandi 2014-06-17 17:43:43 +02:00
parent e86b72e6e9
commit 3b298478a3
3 changed files with 13 additions and 14 deletions

View File

@ -1157,7 +1157,7 @@ static void opencl_detect(bool hotplug)
cgpu->threads = 1; cgpu->threads = 1;
#endif #endif
cgpu->virtual_gpu = i; cgpu->virtual_gpu = i;
cgpu->algorithm = *opt_algorithm; cgpu->algorithm = opt_algorithm;
add_cgpu(cgpu); add_cgpu(cgpu);
} }

View File

@ -990,7 +990,7 @@ extern int opt_queue;
extern int opt_scantime; extern int opt_scantime;
extern int opt_expiry; extern int opt_expiry;
extern algorithm_t *opt_algorithm; extern algorithm_t opt_algorithm;
extern cglock_t control_lock; extern cglock_t control_lock;
extern pthread_mutex_t hash_lock; extern pthread_mutex_t hash_lock;

View File

@ -98,7 +98,7 @@ int opt_queue = 1;
int opt_scantime = 7; int opt_scantime = 7;
int opt_expiry = 28; int opt_expiry = 28;
algorithm_t *opt_algorithm; algorithm_t opt_algorithm;
unsigned long long global_hashrate; unsigned long long global_hashrate;
unsigned long global_quota_gcd = 1; unsigned long global_quota_gcd = 1;
@ -528,7 +528,7 @@ struct pool *add_pool(void)
pool->name = strdup(buf); pool->name = strdup(buf);
/* Algorithm */ /* Algorithm */
pool->algorithm = *opt_algorithm; pool->algorithm = opt_algorithm;
pools = (struct pool **)realloc(pools, sizeof(struct pool *) * (total_pools + 2)); pools = (struct pool **)realloc(pools, sizeof(struct pool *) * (total_pools + 2));
pools[total_pools++] = pool; pools[total_pools++] = pool;
@ -1117,8 +1117,8 @@ static void load_temp_cutoffs()
static char *set_algo(const char *arg) static char *set_algo(const char *arg)
{ {
if ((json_array_index < 0) || (total_pools == 0)) { if ((json_array_index < 0) || (total_pools == 0)) {
set_algorithm(opt_algorithm, arg); set_algorithm(&opt_algorithm, arg);
applog(LOG_INFO, "Set default algorithm to %s", opt_algorithm->name); applog(LOG_INFO, "Set default algorithm to %s", opt_algorithm.name);
} else { } else {
set_pool_algorithm(arg); set_pool_algorithm(arg);
} }
@ -1129,9 +1129,9 @@ static char *set_algo(const char *arg)
static char *set_nfactor(const char *arg) static char *set_nfactor(const char *arg)
{ {
if ((json_array_index < 0) || (total_pools == 0)) { if ((json_array_index < 0) || (total_pools == 0)) {
set_algorithm_nfactor(opt_algorithm, (const uint8_t) atoi(arg)); set_algorithm_nfactor(&opt_algorithm, (const uint8_t) atoi(arg));
applog(LOG_INFO, "Set algorithm N-factor to %d (N to %d)", applog(LOG_INFO, "Set algorithm N-factor to %d (N to %d)",
opt_algorithm->nfactor, opt_algorithm->n); opt_algorithm.nfactor, opt_algorithm.n);
} else { } else {
set_pool_nfactor(arg); set_pool_nfactor(arg);
} }
@ -4414,7 +4414,7 @@ void write_config(FILE *fcfg)
if (strcmp(pool->description, "") != 0) { if (strcmp(pool->description, "") != 0) {
fprintf(fcfg, ",\n\t\t\"description\" : \"%s\"", json_escape(pool->description)); fprintf(fcfg, ",\n\t\t\"description\" : \"%s\"", json_escape(pool->description));
} }
if (!cmp_algorithm(&pool->algorithm, opt_algorithm)) { if (!cmp_algorithm(&pool->algorithm, &opt_algorithm)) {
fprintf(fcfg, ",\n\t\t\"algorithm\" : \"%s\"", json_escape(pool->algorithm.name)); fprintf(fcfg, ",\n\t\t\"algorithm\" : \"%s\"", json_escape(pool->algorithm.name));
} }
if (pool->prio != i) { if (pool->prio != i) {
@ -4591,8 +4591,8 @@ void write_config(FILE *fcfg)
} }
if (opt_removedisabled) if (opt_removedisabled)
fprintf(fcfg, ",\n\"remove-disabled\" : true"); fprintf(fcfg, ",\n\"remove-disabled\" : true");
if (strcmp(opt_algorithm->name, "scrypt") != 0) if (strcmp(opt_algorithm.name, "scrypt") != 0)
fprintf(fcfg, ",\n\"algorithm\" : \"%s\"", json_escape(opt_algorithm->name)); fprintf(fcfg, ",\n\"algorithm\" : \"%s\"", json_escape(opt_algorithm.name));
if (opt_api_allow) if (opt_api_allow)
fprintf(fcfg, ",\n\"api-allow\" : \"%s\"", json_escape(opt_api_allow)); fprintf(fcfg, ",\n\"api-allow\" : \"%s\"", json_escape(opt_api_allow));
if (strcmp(opt_api_mcast_addr, API_MCAST_ADDR) != 0) if (strcmp(opt_api_mcast_addr, API_MCAST_ADDR) != 0)
@ -7409,7 +7409,7 @@ static bool input_pool(bool live)
desc = curses_input("Description (optional)"); desc = curses_input("Description (optional)");
if (strcmp(desc, "-1") == 0) strcpy(desc, ""); if (strcmp(desc, "-1") == 0) strcpy(desc, "");
algo = curses_input("Algorithm (optional)"); algo = curses_input("Algorithm (optional)");
if (strcmp(algo, "-1") == 0) strcpy(algo, opt_algorithm->name); if (strcmp(algo, "-1") == 0) strcpy(algo, opt_algorithm.name);
pool = add_pool(); pool = add_pool();
@ -7919,8 +7919,7 @@ int main(int argc, char *argv[])
#endif #endif
/* Default algorithm specified in algorithm.c ATM */ /* Default algorithm specified in algorithm.c ATM */
opt_algorithm = (algorithm_t *)alloca(sizeof(algorithm_t)); set_algorithm(&opt_algorithm, "scrypt");
set_algorithm(opt_algorithm, "scrypt");
devcursor = 8; devcursor = 8;
logstart = devcursor + 1; logstart = devcursor + 1;