Browse Source

Merge branch 'auto_solomine' into bfgminer

Luke Dashjr 11 years ago
parent
commit
690f329f46
1 changed files with 29 additions and 5 deletions
  1. 29 5
      miner.c

+ 29 - 5
miner.c

@@ -6938,6 +6938,10 @@ void write_config(FILE *fcfg)
 	for(i = 0; i < total_pools; i++) {
 	for(i = 0; i < total_pools; i++) {
 		struct pool *pool = pools[i];
 		struct pool *pool = pools[i];
 
 
+		if (pool->failover_only)
+			// Don't write failover-only (automatically added) pools to the config file for now
+			continue;
+		
 		if (pool->quota != 1) {
 		if (pool->quota != 1) {
 			fprintf(fcfg, "%s\n\t{\n\t\t\"quota\" : \"%d;%s\",", i > 0 ? "," : "",
 			fprintf(fcfg, "%s\n\t{\n\t\t\"quota\" : \"%d;%s\",", i > 0 ? "," : "",
 				pool->quota,
 				pool->quota,
@@ -10971,7 +10975,7 @@ bool _add_local_gbt(const char * const filepath, void *userp)
 	const bool * const live_p = userp;
 	const bool * const live_p = userp;
 	struct pool *pool;
 	struct pool *pool;
 	char buf[0x100];
 	char buf[0x100];
-	char *rpcuser = NULL, *rpcpass = NULL;
+	char *rpcuser = NULL, *rpcpass = NULL, *rpcconnect = NULL;
 	int rpcport = 0, rpcssl = -101;
 	int rpcport = 0, rpcssl = -101;
 	FILE * const F = fopen(filepath, "r");
 	FILE * const F = fopen(filepath, "r");
 	if (!F)
 	if (!F)
@@ -10990,9 +10994,12 @@ bool _add_local_gbt(const char * const filepath, void *userp)
 		else
 		else
 		if (!strncasecmp(buf, "rpcssl=", 7))
 		if (!strncasecmp(buf, "rpcssl=", 7))
 			rpcssl = atoi(&buf[7]);
 			rpcssl = atoi(&buf[7]);
+		else
+		if (!strncasecmp(buf, "rpcconnect=", 11))
+			rpcconnect = trimmed_strdup(&buf[11]);
 		else
 		else
 			continue;
 			continue;
-		if (rpcuser && rpcpass && rpcport && rpcssl != -101)
+		if (rpcuser && rpcpass && rpcport && rpcssl != -101 && rpcconnect)
 			break;
 			break;
 	}
 	}
 	
 	
@@ -11017,9 +11024,26 @@ err:
 	
 	
 	const int uri_sz = 0x30;
 	const int uri_sz = 0x30;
 	char * const uri = malloc(uri_sz);
 	char * const uri = malloc(uri_sz);
-	snprintf(uri, uri_sz, "http%s://localhost:%d/%s#allblocks", rpcssl ? "s" : "", rpcport, have_cbaddr ? "" : "#getcbaddr");
+	snprintf(uri, uri_sz, "http%s://%s:%d/%s#allblocks", rpcssl ? "s" : "", rpcconnect ?: "localhost", rpcport, have_cbaddr ? "" : "#getcbaddr");
 	
 	
-	applog(LOG_DEBUG, "Local bitcoin RPC server on port %d found in %s", rpcport, filepath);
+	char hfuri[0x40];
+	if (rpcconnect)
+		snprintf(hfuri, sizeof(hfuri), "%s:%d", rpcconnect, rpcport);
+	else
+		snprintf(hfuri, sizeof(hfuri), "port %d", rpcport);
+	applog(LOG_DEBUG, "Local bitcoin RPC server on %s found in %s", hfuri, filepath);
+	
+	for (int i = 0; i < total_pools; ++i)
+	{
+		struct pool *pool = pools[i];
+		
+		if (!(strcmp(pool->rpc_url, uri) || strcmp(pool->rpc_pass, rpcpass)))
+		{
+			applog(LOG_DEBUG, "Server on %s is already configured, not adding as failover", hfuri);
+			free(uri);
+			goto err;
+		}
+	}
 	
 	
 	pool = add_pool();
 	pool = add_pool();
 	if (!pool)
 	if (!pool)
@@ -11036,7 +11060,7 @@ err:
 	pool->failover_only = true;
 	pool->failover_only = true;
 	add_pool_details(pool, *live_p, uri, rpcuser, rpcpass);
 	add_pool_details(pool, *live_p, uri, rpcuser, rpcpass);
 	
 	
-	applog(LOG_NOTICE, "Added local bitcoin RPC server on port %d as pool %d", rpcport, pool->pool_no);
+	applog(LOG_NOTICE, "Added local bitcoin RPC server on %s as pool %d", hfuri, pool->pool_no);
 	
 	
 out:
 out:
 	return false;
 	return false;