|
|
@@ -97,7 +97,7 @@ struct strategies strategies[] = {
|
|
|
{ "Balance" },
|
|
|
};
|
|
|
|
|
|
-static char packagename[255];
|
|
|
+static char packagename[256];
|
|
|
|
|
|
bool opt_protocol;
|
|
|
static bool opt_benchmark;
|
|
|
@@ -260,7 +260,7 @@ static char *current_hash;
|
|
|
static uint32_t current_block_id;
|
|
|
char *current_fullhash;
|
|
|
static char datestamp[40];
|
|
|
-static char blocktime[30];
|
|
|
+static char blocktime[32];
|
|
|
struct timeval block_timeval;
|
|
|
static char best_share[8] = "0";
|
|
|
static uint64_t best_diff = 0;
|
|
|
@@ -1731,11 +1731,6 @@ static bool work_decode(struct pool *pool, struct work *work, json_t *val)
|
|
|
calc_midstate(work);
|
|
|
}
|
|
|
|
|
|
- if (!jobj_binary(res_val, "hash1", work->hash1, sizeof(work->hash1), false)) {
|
|
|
- // Always the same anyway
|
|
|
- memcpy(work->hash1, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1\0\0", 64);
|
|
|
- }
|
|
|
-
|
|
|
if (unlikely(!jobj_binary(res_val, "target", work->target, sizeof(work->target), true))) {
|
|
|
applog(LOG_ERR, "JSON inval target");
|
|
|
return false;
|
|
|
@@ -2030,7 +2025,7 @@ static void get_statline(char *buf, struct cgpu_info *cgpu)
|
|
|
static void text_print_status(int thr_id)
|
|
|
{
|
|
|
struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
|
|
|
- char logline[255];
|
|
|
+ char logline[256];
|
|
|
|
|
|
if (cgpu) {
|
|
|
get_statline(logline, cgpu);
|
|
|
@@ -2107,7 +2102,7 @@ static void curses_print_devstatus(int thr_id)
|
|
|
{
|
|
|
static int awidth = 1, rwidth = 1, hwwidth = 1, uwidth = 1;
|
|
|
struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
|
|
|
- char logline[255];
|
|
|
+ char logline[256];
|
|
|
char cHr[h2bs_fmt_size[H2B_NOUNIT]], aHr[h2bs_fmt_size[H2B_NOUNIT]], uHr[h2bs_fmt_size[H2B_SHORT]];
|
|
|
int ypos;
|
|
|
|
|
|
@@ -2449,7 +2444,7 @@ share_result(json_t *val, json_t *res, json_t *err, const struct work *work,
|
|
|
pool->seq_rejects++;
|
|
|
applog(LOG_DEBUG, "PROOF OF WORK RESULT: false (booooo)");
|
|
|
if (!QUIET) {
|
|
|
- char where[17];
|
|
|
+ char where[20];
|
|
|
char disposition[36] = "reject";
|
|
|
char reason[32];
|
|
|
|
|
|
@@ -2513,7 +2508,7 @@ static const uint64_t diffone = 0xFFFF000000000000ull;
|
|
|
static uint64_t share_diff(const struct work *work)
|
|
|
{
|
|
|
uint64_t *data64, d64;
|
|
|
- char rhash[36];
|
|
|
+ char rhash[32];
|
|
|
uint64_t ret;
|
|
|
|
|
|
swab256(rhash, work->hash);
|
|
|
@@ -2556,7 +2551,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
|
|
|
int rolltime;
|
|
|
uint32_t *hash32;
|
|
|
struct timeval tv_submit, tv_submit_reply;
|
|
|
- char hashshow[64 + 1] = "";
|
|
|
+ char hashshow[64 + 4] = "";
|
|
|
char worktime[200] = "";
|
|
|
|
|
|
if (work->tmpl) {
|
|
|
@@ -2678,7 +2673,7 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
|
|
|
if (!opt_realquiet)
|
|
|
print_status(thr_id);
|
|
|
if (!want_per_device_stats) {
|
|
|
- char logline[255];
|
|
|
+ char logline[256];
|
|
|
|
|
|
get_statline(logline, cgpu);
|
|
|
applog(LOG_INFO, "%s", logline);
|
|
|
@@ -2756,7 +2751,7 @@ static void calc_diff(struct work *work, int known)
|
|
|
|
|
|
if (opt_scrypt) {
|
|
|
uint64_t *data64, d64;
|
|
|
- char rtarget[36];
|
|
|
+ char rtarget[32];
|
|
|
|
|
|
swab256(rtarget, work->target);
|
|
|
data64 = (uint64_t *)(rtarget + 2);
|
|
|
@@ -5906,7 +5901,7 @@ static struct work *clone_work(struct work *work)
|
|
|
|
|
|
static void gen_hash(unsigned char *data, unsigned char *hash, int len)
|
|
|
{
|
|
|
- unsigned char hash1[36];
|
|
|
+ unsigned char hash1[32];
|
|
|
|
|
|
sha2(data, len, hash1, false);
|
|
|
sha2(hash1, 32, hash, false);
|
|
|
@@ -5918,7 +5913,7 @@ static void gen_hash(unsigned char *data, unsigned char *hash, int len)
|
|
|
* cover a huge range of difficulty targets, though not all 256 bits' worth */
|
|
|
static void set_work_target(struct work *work, double diff)
|
|
|
{
|
|
|
- unsigned char rtarget[36], target[36];
|
|
|
+ unsigned char rtarget[32], target[32];
|
|
|
double d64;
|
|
|
uint64_t *data64, h64;
|
|
|
|
|
|
@@ -5952,9 +5947,9 @@ static void set_work_target(struct work *work, double diff)
|
|
|
* other means to detect when the pool has died in stratum_thread */
|
|
|
static void gen_stratum_work(struct pool *pool, struct work *work)
|
|
|
{
|
|
|
- unsigned char *coinbase, merkle_root[36], merkle_sha[68], *merkle_hash;
|
|
|
- char header[260], hash1[132], *nonce2;
|
|
|
+ unsigned char *coinbase, merkle_root[32], merkle_sha[64], *merkle_hash;
|
|
|
int len, cb1_len, n1_len, cb2_len, i;
|
|
|
+ char header[260], *nonce2;
|
|
|
uint32_t *data32, *swap32;
|
|
|
|
|
|
memset(work->job_id, 0, 64);
|
|
|
@@ -5980,7 +5975,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
|
|
|
gen_hash(coinbase, merkle_root, len);
|
|
|
memcpy(merkle_sha, merkle_root, 32);
|
|
|
for (i = 0; i < pool->swork.merkles; i++) {
|
|
|
- unsigned char merkle_bin[36];
|
|
|
+ unsigned char merkle_bin[32];
|
|
|
|
|
|
hex2bin(merkle_bin, pool->swork.merkle[i], 32);
|
|
|
memcpy(merkle_sha + 32, merkle_bin, 32);
|
|
|
@@ -6023,9 +6018,6 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
|
|
|
if (unlikely(!hex2bin(work->data, header, 128)))
|
|
|
quit(1, "Failed to convert header to data in gen_stratum_work");
|
|
|
calc_midstate(work);
|
|
|
- sprintf(hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000");
|
|
|
- if (unlikely(!hex2bin(work->hash1, hash1, 64)))
|
|
|
- quit(1, "Failed to convert hash1 in gen_stratum_work");
|
|
|
|
|
|
set_work_target(work, work->sdiff);
|
|
|
|
|
|
@@ -6560,7 +6552,7 @@ static struct pool *select_longpoll_pool(struct pool *cp)
|
|
|
for (i = 0; i < total_pools; i++) {
|
|
|
struct pool *pool = pools[i];
|
|
|
|
|
|
- if (pool->lp_url)
|
|
|
+ if (pool->has_stratum || pool->lp_url)
|
|
|
return pool;
|
|
|
}
|
|
|
return NULL;
|
|
|
@@ -6605,19 +6597,25 @@ static void *longpoll_thread(void *userdata)
|
|
|
curl = curl_easy_init();
|
|
|
if (unlikely(!curl)) {
|
|
|
applog(LOG_ERR, "CURL initialisation failed");
|
|
|
- goto out;
|
|
|
+ return NULL;
|
|
|
}
|
|
|
|
|
|
retry_pool:
|
|
|
pool = select_longpoll_pool(cp);
|
|
|
if (!pool) {
|
|
|
- applog(LOG_WARNING, "No suitable long-poll found for pool %s", cp->rpc_url);
|
|
|
+ applog(LOG_WARNING, "No suitable long-poll found for %s", cp->rpc_url);
|
|
|
while (!pool) {
|
|
|
sleep(60);
|
|
|
pool = select_longpoll_pool(cp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (pool->has_stratum) {
|
|
|
+ applog(LOG_WARNING, "Block change for %s detection via %s stratum",
|
|
|
+ cp->rpc_url, pool->rpc_url);
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
+
|
|
|
/* Any longpoll from any pool is enough for this to be true */
|
|
|
have_longpoll = true;
|
|
|
|
|
|
@@ -6628,7 +6626,7 @@ retry_pool:
|
|
|
if (cp == pool)
|
|
|
applog(LOG_WARNING, "Long-polling activated for %s (%s)", lp_url, pool_protocol_name(pool->lp_proto));
|
|
|
else
|
|
|
- applog(LOG_WARNING, "Long-polling activated for pool %s via %s (%s)", cp->rpc_url, lp_url, pool_protocol_name(pool->lp_proto));
|
|
|
+ applog(LOG_WARNING, "Long-polling activated for %s via %s (%s)", cp->rpc_url, lp_url, pool_protocol_name(pool->lp_proto));
|
|
|
}
|
|
|
|
|
|
while (42) {
|
|
|
@@ -6683,8 +6681,14 @@ retry_pool:
|
|
|
lpfail:
|
|
|
sleep(30);
|
|
|
}
|
|
|
+
|
|
|
if (pool != cp) {
|
|
|
pool = select_longpoll_pool(cp);
|
|
|
+ if (pool->has_stratum) {
|
|
|
+ applog(LOG_WARNING, "Block change for %s detection via %s stratum",
|
|
|
+ cp->rpc_url, pool->rpc_url);
|
|
|
+ break;
|
|
|
+ }
|
|
|
if (unlikely(!pool))
|
|
|
goto retry_pool;
|
|
|
}
|
|
|
@@ -6694,8 +6698,7 @@ lpfail:
|
|
|
}
|
|
|
|
|
|
out:
|
|
|
- if (curl)
|
|
|
- curl_easy_cleanup(curl);
|
|
|
+ curl_easy_cleanup(curl);
|
|
|
|
|
|
return NULL;
|
|
|
}
|