Skip to content

Commit

Permalink
New --skip-security-checks option to allow miners to skip checks when…
Browse files Browse the repository at this point in the history
… it saves bandwidth
  • Loading branch information
luke-jr committed Dec 4, 2012
1 parent cda5e29 commit 2708f34
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Options for both config file and command line:
--scrypt Use the scrypt algorithm for mining (litecoin only)
--sharelog <arg> Append share log to file
--shares <arg> Quit after mining N shares (default: unlimited)
--skip-security-checks <arg> Skip security checks sometimes to save bandwidth; only check 1/<arg>th of the time (default: never skip)
--socks-proxy <arg> Set socks4 proxy (host:port) for all pools without a proxy specified
--syslog Use system log for output messages (default: standard error)
--temp-cutoff <arg> Temperature where a device will be automatically disabled, one value or comma separated list (default: 95)
Expand Down
6 changes: 6 additions & 0 deletions cgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ static char packagename[255];
bool opt_protocol;
static bool opt_benchmark;
bool have_longpoll;
int opt_skip_checks;
bool want_per_device_stats;
bool use_syslog;
bool opt_quiet;
Expand Down Expand Up @@ -1055,6 +1056,9 @@ static struct opt_table opt_config_table[] = {
OPT_WITH_ARG("--shares",
opt_set_intval, NULL, &opt_shares,
"Quit after mining N shares (default: unlimited)"),
OPT_WITH_ARG("--skip-security-checks",
set_int_0_to_9999, NULL, &opt_skip_checks,
"Skip security checks sometimes to save bandwidth; only check 1/<arg>th of the time (default: never skip)"),
OPT_WITH_ARG("--socks-proxy",
opt_set_charp, NULL, &opt_socks_proxy,
"Set socks4 proxy (host:port)"),
Expand Down Expand Up @@ -4349,6 +4353,8 @@ static void *stratum_thread(void *userdata)

pthread_detach(pthread_self());

srand(time(NULL) + (intptr_t)userdata);

while (42) {
struct timeval timeout;
fd_set rd;
Expand Down
2 changes: 2 additions & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ struct pool;

extern bool opt_protocol;
extern bool have_longpoll;
extern int opt_skip_checks;
extern char *opt_kernel_path;
extern char *opt_socks_proxy;
extern char *cgminer_path;
Expand Down Expand Up @@ -799,6 +800,7 @@ struct stratum_work {
int merkles;
int diff;

bool transparency_probed;
time_t transparency_time;
bool opaque;
};
Expand Down
4 changes: 3 additions & 1 deletion util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
pool->getwork_requested++;
total_getworks++;

if (merkles)
if ((merkles && (!pool->swork.transparency_probed || rand() <= RAND_MAX / (opt_skip_checks + 1))) || pool->swork.transparency_time != (time_t)-1)
{
// Request transaction data to discourage pools from doing anything shady
char s[1024];
Expand All @@ -1129,6 +1129,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
stratum_send(pool, s, sLen);
if ((!pool->swork.opaque) && pool->swork.transparency_time == (time_t)-1)
pool->swork.transparency_time = time(NULL);
pool->swork.transparency_probed = true;
}

return true;
Expand Down Expand Up @@ -1336,6 +1337,7 @@ bool initiate_stratum(struct pool *pool)

mutex_lock(&pool->stratum_lock);
pool->stratum_active = false;
pool->swork.transparency_probed = false;
if (!pool->stratum_curl) {
pool->stratum_curl = curl_easy_init();
if (unlikely(!pool->stratum_curl))
Expand Down

0 comments on commit 2708f34

Please sign in to comment.