Browse Source

Fixed problem with stratum support when mining FC, GRS and TWE. Added --difficulty-multiplier parameter for controlling stratum difficulty multiplier.

djm34
phm 11 years ago
parent
commit
7678db6801
  1. 21
      sgminer.c
  2. 5
      util.c

21
sgminer.c

@ -150,6 +150,7 @@ int opt_tcp_keepalive = 30;
#else #else
int opt_tcp_keepalive; int opt_tcp_keepalive;
#endif #endif
double opt_diff_mult = 1.0;
char *opt_kernel_path; char *opt_kernel_path;
char *sgminer_path; char *sgminer_path;
@ -1055,6 +1056,18 @@ static char *set_null(const char __maybe_unused *arg)
return NULL; return NULL;
} }
char *set_difficulty_multiplier(char *arg)
{
char **endptr = NULL;
if (!(arg && arg[0]))
return "Invalid parameters for set difficulty multiplier";
opt_diff_mult = strtod(arg, endptr);
if (opt_diff_mult == 0 || endptr == arg)
return "Invalid value passed to set difficulty multiplier";
return NULL;
}
/* These options are available from config file or commandline */ /* These options are available from config file or commandline */
static struct opt_table opt_config_table[] = { static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--api-allow", OPT_WITH_ARG("--api-allow",
@ -1354,6 +1367,9 @@ static struct opt_table opt_config_table[] = {
"Display extra work time debug information"), "Display extra work time debug information"),
OPT_WITH_ARG("--pools", OPT_WITH_ARG("--pools",
opt_set_bool, NULL, NULL, opt_hidden), opt_set_bool, NULL, NULL, opt_hidden),
OPT_WITH_ARG("--difficulty-multiplier",
set_difficulty_multiplier, NULL, NULL,
"Difficulty multiplier for jobs received from stratum pools"),
OPT_ENDTABLE OPT_ENDTABLE
}; };
@ -5908,7 +5924,10 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
cg_dwlock(&pool->data_lock); cg_dwlock(&pool->data_lock);
/* Generate merkle root */ /* Generate merkle root */
gen_hash(pool->coinbase, merkle_root, pool->swork.cb_len); if (gpus[0].kernel == KL_FUGUECOIN || gpus[0].kernel == KL_GROESTLCOIN || gpus[0].kernel == KL_TWECOIN)
sha256(pool->coinbase, pool->swork.cb_len, merkle_root);
else
gen_hash(pool->coinbase, merkle_root, pool->swork.cb_len);
memcpy(merkle_sha, merkle_root, 32); memcpy(merkle_sha, merkle_root, 32);
for (i = 0; i < pool->swork.merkles; i++) { for (i = 0; i < pool->swork.merkles; i++) {
memcpy(merkle_sha + 32, pool->swork.merkle_bin[i], 32); memcpy(merkle_sha + 32, pool->swork.merkle_bin[i], 32);

5
util.c

@ -45,8 +45,7 @@
#include "util.h" #include "util.h"
#define DEFAULT_SOCKWAIT 60 #define DEFAULT_SOCKWAIT 60
#define DM_SELECT(x, y, z) (dm_mode == DM_BITCOIN ? x : (dm_mode == DM_QUARKCOIN ? y : z)) extern double opt_diff_mult;
extern enum diff_calc_mode dm_mode;
bool successful_connect = false; bool successful_connect = false;
static void keep_sockalive(SOCKETTYPE fd) static void keep_sockalive(SOCKETTYPE fd)
@ -1644,7 +1643,7 @@ static bool parse_diff(struct pool *pool, json_t *val)
{ {
double old_diff, diff; double old_diff, diff;
diff = json_number_value(json_array_get(val, 0)) * DM_SELECT(1, 256, 1); diff = json_number_value(json_array_get(val, 0)) * opt_diff_mult;
if (diff == 0) if (diff == 0)
return false; return false;

Loading…
Cancel
Save