From dcf9769ff20eb1319488e2d0c1131b0a570bb4d9 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 28 Mar 2017 13:22:42 -0400 Subject: [PATCH] gostd added --- cpu-miner.c | 6 ++++++ cpuminer-config.h | 25 +++++++++++-------------- gost.c | 31 +++++++++++++++++++++++++++++++ miner.h | 3 +++ 4 files changed, 51 insertions(+), 14 deletions(-) diff --git a/cpu-miner.c b/cpu-miner.c index 7a75bdc..e1ea4be 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -105,6 +105,7 @@ enum sha256_algos { ALGO_SHA256D, /* SHA-256d */ ALGO_QUARK, ALGO_X, + ALGO_GOSTD }; static const char *algo_names[] = { @@ -112,6 +113,7 @@ static const char *algo_names[] = { [ALGO_SHA256D] = "sha256d", [ALGO_QUARK] = "quark", [ALGO_X] = "X11", + [ALGO_GOSTD] = "gostd", }; bool opt_hashdebug = false; @@ -796,6 +798,10 @@ static void *miner_thread(void *userdata) rc = scanhash_X(thr_id, work.data, work.target, max_nonce, &hashes_done); break; + case ALGO_GOSTD: + rc = scanhash_gostd(thr_id, work.data, work.target, + max_nonce, &hashes_done); + break; default: /* should never happen */ goto out; diff --git a/cpuminer-config.h b/cpuminer-config.h index c0147dc..9cce557 100644 --- a/cpuminer-config.h +++ b/cpuminer-config.h @@ -14,7 +14,7 @@ /* Define to 1 if you have and it should be used (not on Ultrix). */ -/* #undef HAVE_ALLOCA_H */ +#define HAVE_ALLOCA_H 1 /* Define to 1 if you have the declaration of `be32dec', and to 0 if you don't. */ @@ -57,7 +57,7 @@ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ -/* #undef HAVE_SYSLOG_H */ +#define HAVE_SYSLOG_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_SYS_ENDIAN_H */ @@ -69,7 +69,7 @@ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_SYSCTL_H */ +#define HAVE_SYS_SYSCTL_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 @@ -78,25 +78,25 @@ #define HAVE_UNISTD_H 1 /* Defined if libcurl supports AsynchDNS */ -/* #undef LIBCURL_FEATURE_ASYNCHDNS */ +#define LIBCURL_FEATURE_ASYNCHDNS 1 /* Defined if libcurl supports IDN */ -/* #undef LIBCURL_FEATURE_IDN */ +#define LIBCURL_FEATURE_IDN 1 /* Defined if libcurl supports IPv6 */ -/* #undef LIBCURL_FEATURE_IPV6 */ +#define LIBCURL_FEATURE_IPV6 1 /* Defined if libcurl supports KRB4 */ /* #undef LIBCURL_FEATURE_KRB4 */ /* Defined if libcurl supports libz */ -/* #undef LIBCURL_FEATURE_LIBZ */ +#define LIBCURL_FEATURE_LIBZ 1 /* Defined if libcurl supports NTLM */ -/* #undef LIBCURL_FEATURE_NTLM */ +#define LIBCURL_FEATURE_NTLM 1 /* Defined if libcurl supports SSL */ -/* #undef LIBCURL_FEATURE_SSL */ +#define LIBCURL_FEATURE_SSL 1 /* Defined if libcurl supports SSPI */ /* #undef LIBCURL_FEATURE_SSPI */ @@ -111,13 +111,13 @@ #define LIBCURL_PROTOCOL_FTP 1 /* Defined if libcurl supports FTPS */ -/* #undef LIBCURL_PROTOCOL_FTPS */ +#define LIBCURL_PROTOCOL_FTPS 1 /* Defined if libcurl supports HTTP */ #define LIBCURL_PROTOCOL_HTTP 1 /* Defined if libcurl supports HTTPS */ -/* #undef LIBCURL_PROTOCOL_HTTPS */ +#define LIBCURL_PROTOCOL_HTTPS 1 /* Defined if libcurl supports IMAP */ #define LIBCURL_PROTOCOL_IMAP 1 @@ -140,9 +140,6 @@ /* Defined if libcurl supports TFTP */ #define LIBCURL_PROTOCOL_TFTP 1 -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -/* #undef NO_MINUS_C_MINUS_O */ - /* Name of package */ #define PACKAGE "cpuminer" diff --git a/gost.c b/gost.c index 134ebbd..f60975d 100644 --- a/gost.c +++ b/gost.c @@ -38,6 +38,7 @@ #include #include +#include "miner.h" #include "sph_gost.h" #ifdef __cplusplus @@ -1095,6 +1096,36 @@ sph_gost512_addbits_and_close(void *cc, unsigned ub, unsigned n, void *dst) //gost_close64(cc, ub, n, dst); } +int scanhash_gostd(int thr_id, uint32_t *pdata, const uint32_t *ptarget, + uint32_t max_nonce, unsigned long *hashes_done) +{ + uint32_t data[80] __attribute__((aligned(128))); + uint32_t hash[8] __attribute__((aligned(32))); + uint32_t digest[16] __attribute__((aligned(64))); + uint32_t n = pdata[19] - 1; + const uint32_t first_nonce = pdata[19]; + const uint32_t Htarg = ptarget[7]; + + memcpy(data, pdata, 80); + + do + { + data[3] = ++n; + sph_gost512 (digest, data, 80); + sph_gost256 (hash, digest, 64); + if (swab32(hash[7]) <= Htarg) + { + pdata[19] = data[3]; + *hashes_done = n - first_nonce + 1; + return 1; + } + } while (n < max_nonce && !work_restart[thr_id].restart); + + *hashes_done = n - first_nonce + 1; + pdata[19] = n; + return 0; +} + #ifdef __cplusplus } diff --git a/miner.h b/miner.h index bfa1795..2437f63 100644 --- a/miner.h +++ b/miner.h @@ -151,6 +151,9 @@ void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap); extern int scanhash_sha256d(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done); +extern int scanhash_gostd(int thr_id, uint32_t *pdata, + const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done); + extern int scanhash_quark(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done);