Special casing testnet turns out to be unnecessary since the diff is still relative to an absolute reference value.

This commit is contained in:
Con Kolivas 2023-05-25 18:03:29 +10:00
parent e829346808
commit 240d74fe5c
5 changed files with 2 additions and 13 deletions

View File

@ -4,14 +4,12 @@
"url" : "localhost:8332",
"auth" : "user",
"pass" : "pass",
"testnet" : false,
"notify" : true
},
{
"url" : "backup:8332",
"auth" : "user",
"pass" : "pass",
"testnet" : false,
"notify" : false
}
],

View File

@ -1251,14 +1251,12 @@ static void parse_btcds(ckpool_t *ckp, const json_t *arr_val, const int arr_size
ckp->btcdauth = ckzalloc(sizeof(char *) * arr_size);
ckp->btcdpass = ckzalloc(sizeof(char *) * arr_size);
ckp->btcdnotify = ckzalloc(sizeof(bool *) * arr_size);
ckp->btcdtestnet = ckzalloc(sizeof(bool *) * arr_size);
for (i = 0; i < arr_size; i++) {
val = json_array_get(arr_val, i);
json_get_string(&ckp->btcdurl[i], val, "url");
json_get_string(&ckp->btcdauth[i], val, "auth");
json_get_string(&ckp->btcdpass[i], val, "pass");
json_get_bool(&ckp->btcdnotify[i], val, "notify");
json_get_bool(&ckp->btcdtestnet[i], val, "testnet");
}
}

View File

@ -120,7 +120,6 @@ struct server_instance {
char *auth;
char *pass;
bool notify;
bool testnet;
bool alive;
connsock_t cs;
};
@ -217,9 +216,6 @@ struct ckpool_instance {
/* Should we disable the throbber */
bool quiet;
/* Are we mining on testnet */
bool testnet;
/* Have we given warnings about the inability to raise buf sizes */
bool wmem_warn;
bool rmem_warn;
@ -230,7 +226,6 @@ struct ckpool_instance {
char **btcdauth;
char **btcdpass;
bool *btcdnotify;
bool *btcdtestnet;
int blockpoll; // How frequently in ms to poll bitcoind for block updates
int nonce1length; // Extranonce1 length
int nonce2length; // Extranonce2 length

View File

@ -299,7 +299,6 @@ retry:
goto retry;
living:
gdata->current_si = alive;
ckp->testnet = alive->testnet;
cs = &alive->cs;
LOGINFO("Connected to live server %s:%s", cs->url, cs->port);
send_proc(ckp->connector, alive ? "accept" : "reject");
@ -3296,7 +3295,6 @@ static void setup_servers(ckpool_t *ckp)
si->auth = ckp->btcdauth[i];
si->pass = ckp->btcdpass[i];
si->notify = ckp->btcdnotify[i];
si->testnet = ckp->btcdtestnet[i];
si->id = i;
cs = &si->cs;
cs->ckp = ckp;

View File

@ -1036,7 +1036,7 @@ static void add_base(ckpool_t *ckp, sdata_t *sdata, workbase_t *wb, bool *new_bl
wb->network_diff = 1;
stats->network_diff = wb->network_diff;
if (stats->network_diff != old_diff)
LOGWARNING("Network diff set to %.1f%s", stats->network_diff, ckp->testnet ? " in testnet mode!": "");
LOGWARNING("Network diff set to %.1f", stats->network_diff);
len = strlen(ckp->logdir) + 8 + 1 + 16 + 1;
wb->logdir = ckzalloc(len);
@ -5724,7 +5724,7 @@ test_blocksolve(const stratum_instance_t *client, const workbase_t *wb, const uc
bool ret;
/* Submit anything over 99.9% of the diff in case of rounding errors */
network_diff = ckp->testnet ? sdata->current_workbase->network_diff * 0.499 : sdata->current_workbase->network_diff * 0.999;
network_diff = sdata->current_workbase->network_diff * 0.999;
if (likely(diff < network_diff))
return;