Browse Source

Merge branch 'stratum_transparency' into bfgminer

Conflicts:
	miner.c
Luke Dashjr 13 years ago
parent
commit
ecee542954
4 changed files with 12 additions and 0 deletions
  1. 1 0
      README
  2. 6 0
      miner.c
  3. 2 0
      miner.h
  4. 3 0
      util.c

+ 1 - 0
README

@@ -161,6 +161,7 @@ Options for both config file and command line:
 --scrypt            Use the scrypt algorithm for mining (non-bitcoin)
 --scrypt            Use the scrypt algorithm for mining (non-bitcoin)
 --sharelog <arg>    Append share log to file
 --sharelog <arg>    Append share log to file
 --shares <arg>      Quit after mining N shares (default: unlimited)
 --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
 --socks-proxy <arg> Set socks4 proxy (host:port) for all pools without a proxy specified
 --submit-threads    Maximum number of share submission threads (default: 64)
 --submit-threads    Maximum number of share submission threads (default: 64)
 --syslog            Use system log for output messages (default: standard error)
 --syslog            Use system log for output messages (default: standard error)

+ 6 - 0
miner.c

@@ -117,6 +117,7 @@ const
 char *opt_coinbase_sig;
 char *opt_coinbase_sig;
 static bool want_stratum = true;
 static bool want_stratum = true;
 bool have_longpoll;
 bool have_longpoll;
+int opt_skip_checks;
 bool want_per_device_stats;
 bool want_per_device_stats;
 bool use_syslog;
 bool use_syslog;
 bool opt_quiet;
 bool opt_quiet;
@@ -1314,6 +1315,9 @@ static struct opt_table opt_config_table[] = {
 	OPT_WITH_ARG("--shares",
 	OPT_WITH_ARG("--shares",
 		     opt_set_intval, NULL, &opt_shares,
 		     opt_set_intval, NULL, &opt_shares,
 		     "Quit after mining N shares (default: unlimited)"),
 		     "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_WITH_ARG("--socks-proxy",
 		     opt_set_charp, NULL, &opt_socks_proxy,
 		     opt_set_charp, NULL, &opt_socks_proxy,
 		     "Set socks4 proxy (host:port)"),
 		     "Set socks4 proxy (host:port)"),
@@ -5500,6 +5504,8 @@ static void *stratum_thread(void *userdata)
 
 
 	RenameThread("stratum");
 	RenameThread("stratum");
 
 
+	srand(time(NULL) + (intptr_t)userdata);
+
 	while (42) {
 	while (42) {
 		struct timeval timeout;
 		struct timeval timeout;
 		fd_set rd;
 		fd_set rd;

+ 2 - 0
miner.h

@@ -692,6 +692,7 @@ struct pool;
 extern bool opt_protocol;
 extern bool opt_protocol;
 extern char *opt_coinbase_sig;
 extern char *opt_coinbase_sig;
 extern bool have_longpoll;
 extern bool have_longpoll;
+extern int opt_skip_checks;
 extern char *opt_kernel_path;
 extern char *opt_kernel_path;
 extern char *opt_socks_proxy;
 extern char *opt_socks_proxy;
 extern char *cgminer_path;
 extern char *cgminer_path;
@@ -903,6 +904,7 @@ struct stratum_work {
 	int merkles;
 	int merkles;
 	double diff;
 	double diff;
 
 
+	bool transparency_probed;
 	time_t transparency_time;
 	time_t transparency_time;
 	bool opaque;
 	bool opaque;
 };
 };

+ 3 - 0
util.c

@@ -1095,6 +1095,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
 	pool->getwork_requested++;
 	pool->getwork_requested++;
 	total_getworks++;
 	total_getworks++;
 
 
+	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
 		// Request transaction data to discourage pools from doing anything shady
 		char s[1024];
 		char s[1024];
@@ -1105,6 +1106,7 @@ static bool parse_notify(struct pool *pool, json_t *val)
 		stratum_send(pool, s, sLen);
 		stratum_send(pool, s, sLen);
 		if ((!pool->swork.opaque) && pool->swork.transparency_time == (time_t)-1)
 		if ((!pool->swork.opaque) && pool->swork.transparency_time == (time_t)-1)
 			pool->swork.transparency_time = time(NULL);
 			pool->swork.transparency_time = time(NULL);
+		pool->swork.transparency_probed = true;
 	}
 	}
 
 
 	return true;
 	return true;
@@ -1300,6 +1302,7 @@ bool initiate_stratum(struct pool *pool)
 
 
 	mutex_lock(&pool->stratum_lock);
 	mutex_lock(&pool->stratum_lock);
 	pool->stratum_active = false;
 	pool->stratum_active = false;
+	pool->swork.transparency_probed = false;
 	if (!pool->stratum_curl) {
 	if (!pool->stratum_curl) {
 		pool->stratum_curl = curl_easy_init();
 		pool->stratum_curl = curl_easy_init();
 		if (unlikely(!pool->stratum_curl))
 		if (unlikely(!pool->stratum_curl))