From 7e78d84986a1325ad10a8b38b386e11573bb71a8 Mon Sep 17 00:00:00 2001 From: okoto-xyz Date: Sun, 23 Sep 2018 00:52:27 +0900 Subject: [PATCH 1/5] Fix for sapling --- cpu-miner.c | 8 +++----- util.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index 75e196387..a1c4a870e 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -1073,19 +1073,17 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work) /* Assemble block header */ memset(work->data, 0, 160); + work->sapling = be32dec(sctx->job.version) == 5 ? true : false; work->data[0] = le32dec(sctx->job.version); - work->sapling = work->data[0] == 5 ? true : false; for (i = 0; i < 8; i++) work->data[1 + i] = le32dec((uint32_t *)sctx->job.prevhash + i); - if (work->sapling) { - for (i = 0; i < 8; i++) - work->data[27 + i] = le32dec((uint32_t *)sctx->job.finalsaplinghash + i); - } for (i = 0; i < 8; i++) work->data[9 + i] = be32dec((uint32_t *)merkle_root + i); work->data[17] = le32dec(sctx->job.ntime); work->data[18] = le32dec(sctx->job.nbits); if (work->sapling) { + for (i = 0; i < 8; i++) + work->data[20 + i] = le32dec((uint32_t *)sctx->job.finalsaplinghash + i); work->data[28] = 0x80000000; work->data[39] = 0x00000280; } else { diff --git a/util.c b/util.c index 1ce506b92..24e31c452 100644 --- a/util.c +++ b/util.c @@ -1203,7 +1203,7 @@ static bool stratum_notify(struct stratum_ctx *sctx, json_t *params) goto out; } hex2bin(sctx->job.version, version, 4); - ver = le32dec(sctx->job.version); + ver = be32dec(sctx->job.version); if (ver == 5) { finalsaplinghash = json_string_value(json_array_get(params, 9)); if (!finalsaplinghash || strlen(finalsaplinghash) != 64) { From 07527e3ae62014cf48caf8b661fa3020199f6ea8 Mon Sep 17 00:00:00 2001 From: WO Date: Sun, 28 Oct 2018 21:59:52 +0900 Subject: [PATCH 2/5] Add required dll for win32 --- winbuild-cross.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/winbuild-cross.sh b/winbuild-cross.sh index fac9c76dd..33257ebba 100755 --- a/winbuild-cross.sh +++ b/winbuild-cross.sh @@ -19,6 +19,7 @@ CFLAGS="-Wall -O3 -fomit-frame-pointer" mkdir release cp README.txt release/ #cp /usr/i686-w64-mingw32/lib/libwinpthread-1.dll release/ +#cp /usr/lib/gcc/i686-w64-mingw32/5.3-win32/libgcc_s_sjlj-1.dll release/ cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll release/ cp curl/lib/.libs/libcurl-4.dll release/ From cd2883454f6ebd4e009ae66174c8e79593303c6b Mon Sep 17 00:00:00 2001 From: pooler Date: Tue, 15 Mar 2016 20:13:22 +0100 Subject: [PATCH 3/5] Fix memory leaks affecting getblocktemplate --- cpu-miner.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpu-miner.c b/cpu-miner.c index a1c4a870e..742b69c67 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -567,6 +567,7 @@ static bool gbt_work_decode(const json_t *val, struct work *work) goto out; } sha256d(merkle_tree[1 + i], tx, tx_size); + free(tx); if (!submit_coinbase) strcat(work->txs, tx_hex); } @@ -628,7 +629,7 @@ static bool gbt_work_decode(const json_t *val, struct work *work) if (!have_longpoll) { char *lp_uri; tmp = json_object_get(val, "longpolluri"); - lp_uri = json_is_string(tmp) ? strdup(json_string_value(tmp)) : rpc_url; + lp_uri = strdup(json_is_string(tmp) ? json_string_value(tmp) : rpc_url); have_longpoll = true; tq_push(thr_info[longpoll_thr_id].q, lp_uri); } @@ -1155,6 +1156,7 @@ static void *miner_thread(void *userdata) if (!have_stratum && (time(NULL) - g_work_time >= min_scantime || work.data[19] >= end_nonce)) { + work_free(&g_work); if (unlikely(!get_work(mythr, &g_work))) { applog(LOG_ERR, "work retrieval failed, exiting " "mining thread %d", mythr->id); From 8e71bf5c6ea14ec88516966142d647405a61992b Mon Sep 17 00:00:00 2001 From: pooler Date: Thu, 21 Apr 2016 23:44:55 +0200 Subject: [PATCH 4/5] Fix memory leak in the long polling thread --- cpu-miner.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu-miner.c b/cpu-miner.c index 742b69c67..08202bce1 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -1327,6 +1327,7 @@ static void *longpoll_thread(void *userdata) soval = json_object_get(res, "submitold"); submit_old = soval ? json_is_true(soval) : false; pthread_mutex_lock(&g_work_lock); + work_free(&g_work); if (have_gbt) rc = gbt_work_decode(res, &g_work); else From 2814f8555edb1c3721d9269cab2d772dead10cd4 Mon Sep 17 00:00:00 2001 From: WO Date: Sun, 2 Dec 2018 10:29:33 +0900 Subject: [PATCH 5/5] Fix yescrypt_hash function for Sapling --- yescrypt.c | 2 +- yescrypt.h | 4 ++-- yescryptcommon.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/yescrypt.c b/yescrypt.c index 19392f99f..29bed4c2e 100644 --- a/yescrypt.c +++ b/yescrypt.c @@ -31,7 +31,7 @@ int scanhash_yescrypt(int thr_id, uint32_t *pdata, const uint32_t *ptarget, do { pdata[19] = ++n; be32enc(&endiandata[19], n); - yescrypt_hash_sp((unsigned char*) &endiandata, (unsigned char*) hash64); + yescrypt_hash_sp((unsigned char*) &endiandata, perslen, (unsigned char*) hash64); if ((hash64[7] < ptarget[7]) || ((hash64[7] == ptarget[7]) && (hash64[6] < ptarget[6])) && fulltest(hash64, ptarget)) { *hashes_done = n - first_nonce + 1; diff --git a/yescrypt.h b/yescrypt.h index 8fb8b0e24..cdc2a31af 100755 --- a/yescrypt.h +++ b/yescrypt.h @@ -38,8 +38,8 @@ extern "C" { #endif -extern void yescrypt_hash_sp(const char *input, char *output); -extern void yescrypt_hash(const char *input, char *output); +extern void yescrypt_hash_sp(const char *input, int inputlen, char *output); +extern void yescrypt_hash(const char *input, int inputlen, char *output); diff --git a/yescryptcommon.c b/yescryptcommon.c index c0d09185c..f57d132fe 100755 --- a/yescryptcommon.c +++ b/yescryptcommon.c @@ -363,12 +363,12 @@ yescrypt_bsty(const uint8_t * passwd, size_t passwdlen, return retval; } -void yescrypt_hash_sp(const char *input, char *output) +void yescrypt_hash_sp(const char *input, int inputlen, char *output) { - yescrypt_bsty((const uint8_t *)input, 80, (const uint8_t *) input, 80, 2048, 8, 1, (uint8_t *)output, 32); + yescrypt_bsty((const uint8_t *)input, inputlen, (const uint8_t *) input, inputlen, 2048, 8, 1, (uint8_t *)output, 32); } -void yescrypt_hash(const char *input, char *output) +void yescrypt_hash(const char *input, int inputlen, char *output) { - yescrypt_hash_sp(input, output); + yescrypt_hash_sp(input, inputlen, output); }