Skip to content

Commit

Permalink
debug: add -f option to test with reduced diff
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Oct 31, 2014
1 parent 2cf78c9 commit 070ff29
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 12 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Version multi 1.0.6 (Tanguy Pruvot)
- Fix scrypt algo
- More work on VC2013
- Add -f tuning option to test with reduced difficulty

Version multi 1.0.5 (Tanguy Pruvot)

Expand Down
32 changes: 24 additions & 8 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ static int rpc2_bloblen = 0;
static uint32_t rpc2_target = 0;
static char *rpc2_job_id = NULL;
bool aes_ni_supported = false;
double opt_diff_factor = 1.0;
static pthread_mutex_t rpc2_job_lock;
static pthread_mutex_t rpc2_login_lock;

pthread_mutex_t applog_lock;
static pthread_mutex_t stats_lock;

Expand Down Expand Up @@ -260,6 +260,7 @@ Options:\n\
-T, --timeout=N timeout for long polling, in seconds (default: none)\n\
-s, --scantime=N upper bound on time spent scanning current work when\n\
long polling is unavailable, in seconds (default: 5)\n\
-f, --diff Divide difficulty by this factor (std is 1) \n\
-n, --nfactor neoscrypt N-Factor\n\
--coinbase-addr=ADDR payout address for solo mining\n\
--coinbase-sig=TEXT data to insert in the coinbase when possible\n\
Expand Down Expand Up @@ -296,7 +297,7 @@ static char const short_options[] =
#ifdef HAVE_SYSLOG_H
"S"
#endif
"a:c:CDhp:Px:qr:R:s:t:T:o:u:O:Vn:";
"a:c:CDhp:Px:qr:R:s:t:T:o:u:O:Vn:f:";

static struct option const options[] = {
{ "algo", 1, NULL, 'a' },
Expand All @@ -312,7 +313,8 @@ static struct option const options[] = {
{ "no-color", 0, NULL, 1002 },
{ "debug", 0, NULL, 'D' },
{ "help", 0, NULL, 'h' },
{ "nfactor", 0, NULL, 'n' },
{ "diff", 1, NULL, 'f' },
{ "nfactor", 1, NULL, 'n' },
{ "no-gbt", 0, NULL, 1011 },
{ "no-getwork", 0, NULL, 1010 },
{ "no-longpoll", 0, NULL, 1003 },
Expand Down Expand Up @@ -898,7 +900,7 @@ static bool gbt_work_decode(const json_t *val, struct work *work)
return rc;
}

static void share_result(int result, struct work *work, const char *reason)
static int share_result(int result, struct work *work, const char *reason)
{
char s[345];
double hashrate;
Expand Down Expand Up @@ -933,8 +935,15 @@ static void share_result(int result, struct work *work, const char *reason)
break;
}

if (opt_debug && reason)
applog(LOG_DEBUG, "DEBUG: reject reason: %s", reason);
if (reason) {
applog(LOG_WARNING, "reject reason: %s", reason);
if (strncmp(reason, "low difficulty share", 20) == 0) {
opt_diff_factor = (opt_diff_factor * 2.0) / 3.0;
applog(LOG_WARNING, "factor reduced to : %0.2f", opt_diff_factor);
return 0;
}
}
return 1;
}

static bool submit_upstream_work(CURL *curl, struct work *work)
Expand Down Expand Up @@ -1533,10 +1542,10 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
switch (opt_algo) {
case ALGO_SCRYPT:
case ALGO_NEOSCRYPT:
diff_to_target(work->target, sctx->job.diff / 65536.0);
diff_to_target(work->target, sctx->job.diff / (65536.0 * opt_diff_factor));
break;
default:
diff_to_target(work->target, sctx->job.diff);
diff_to_target(work->target, sctx->job.diff / opt_diff_factor);
}
}
}
Expand Down Expand Up @@ -2158,6 +2167,7 @@ static void parse_arg(int key, char *arg, char *pname)
{
char *p;
int v, i;
double d;

switch(key) {
case 'a':
Expand Down Expand Up @@ -2396,6 +2406,12 @@ static void parse_arg(int key, char *arg, char *pname)
}
strcpy(coinbase_sig, arg);
break;
case 'f':
d = atof(arg);
if (d == 0) /* sanity check */
show_usage_and_exit(1);
opt_diff_factor = d;
break;
case 'S':
use_syslog = true;
use_colors = false;
Expand Down
2 changes: 1 addition & 1 deletion elist.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct list_head {
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
inline void __list_add(struct list_head *nlh,
static inline void __list_add(struct list_head *nlh,
struct list_head *prev,
struct list_head *next)
{
Expand Down
2 changes: 1 addition & 1 deletion sha3/blake2s.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static inline void store48(void *dst, uint64_t w)
}

/* prevents compiler optimizing out memset() */
inline void secure_zero_memory(void *v, size_t n)
static inline void secure_zero_memory(void *v, size_t n)
{
volatile uint8_t *p = ( volatile uint8_t * )v;

Expand Down
3 changes: 1 addition & 2 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,7 @@ static bool stratum_set_difficulty(struct stratum_ctx *sctx, json_t *params)
sctx->next_diff = diff;
pthread_mutex_unlock(&sctx->work_lock);

if (opt_debug)
applog(LOG_DEBUG, "Stratum difficulty set to %g", diff);
applog(LOG_WARNING, "Stratum difficulty set to %g", diff);

return true;
}
Expand Down

0 comments on commit 070ff29

Please sign in to comment.