Browse Source

enhance solo mining, update http headers

and prepare next version...
2upstream
Tanguy Pruvot 10 years ago
parent
commit
799b230af2
  1. 18
      ccminer.vcxproj.filters
  2. 2
      configure.ac
  3. 22
      cpu-miner.c
  4. 6
      cpuminer-config.h
  5. 3
      miner.h
  6. 27
      quark/animecoin.cu
  7. 25
      util.c

18
ccminer.vcxproj.filters

@ -31,9 +31,6 @@ @@ -31,9 +31,6 @@
<Filter Include="Source Files\code">
<UniqueIdentifier>{fe39ded0-754b-415f-a284-038a15a0aa55}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\CUDA\jansson">
<UniqueIdentifier>{17b56151-79ec-4a32-bac3-9d94ae7f68fe}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\CUDA\JHA">
<UniqueIdentifier>{d8f2e173-a0a5-455b-8efc-42511b585156}</UniqueIdentifier>
</Filter>
@ -67,25 +64,28 @@ @@ -67,25 +64,28 @@
<Filter Include="Source Files\CUDA\x17">
<UniqueIdentifier>{85dfae6a-66ca-4332-8cec-98ee70cbdf2f}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\jansson">
<UniqueIdentifier>{17b56151-79ec-4a32-bac3-9d94ae7f68fe}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="compat\jansson\dump.c">
<Filter>Source Files\CUDA\jansson</Filter>
<Filter>Source Files\jansson</Filter>
</ClCompile>
<ClCompile Include="compat\jansson\hashtable.c">
<Filter>Source Files\CUDA\jansson</Filter>
<Filter>Source Files\jansson</Filter>
</ClCompile>
<ClCompile Include="compat\jansson\load.c">
<Filter>Source Files\CUDA\jansson</Filter>
<Filter>Source Files\jansson</Filter>
</ClCompile>
<ClCompile Include="compat\jansson\strbuffer.c">
<Filter>Source Files\CUDA\jansson</Filter>
<Filter>Source Files\jansson</Filter>
</ClCompile>
<ClCompile Include="compat\jansson\utf.c">
<Filter>Source Files\CUDA\jansson</Filter>
<Filter>Source Files\jansson</Filter>
</ClCompile>
<ClCompile Include="compat\jansson\value.c">
<Filter>Source Files\CUDA\jansson</Filter>
<Filter>Source Files\jansson</Filter>
</ClCompile>
<ClCompile Include="compat\getopt\getopt_long.c">
<Filter>Source Files\getopt</Filter>

2
configure.ac

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
AC_INIT([ccminer], [2014.09.11])
AC_INIT([ccminer], [2014.09.28])
AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM

22
cpu-miner.c

@ -362,6 +362,10 @@ struct work { @@ -362,6 +362,10 @@ struct work {
uint32_t scanned_from;
uint32_t scanned_to;
/* deprecated, but maybe useful
for some 256-bit algos */
uint32_t midstate[8];
};
static struct work g_work;
@ -421,6 +425,13 @@ static bool work_decode(const json_t *val, struct work *work) @@ -421,6 +425,13 @@ static bool work_decode(const json_t *val, struct work *work)
for (i = 0; i < ARRAY_SIZE(work->target); i++)
work->target[i] = le32dec(work->target + i);
if (opt_algo == ALGO_ANIME || opt_algo == ALGO_BLAKE /* || opt_algo == ALGO_SHA256D || opt_algo == ALGO_SCRYPT */) {
jobj_binary(val, "midstate", work->midstate, sizeof(work->midstate));
}
/* use work ntime as job id (solo-mining) */
cbin2hex(work->job_id, (const char*)&work->data[17], 4);
return true;
err_out:
@ -594,8 +605,13 @@ static bool get_upstream_work(CURL *curl, struct work *work) @@ -594,8 +605,13 @@ static bool get_upstream_work(CURL *curl, struct work *work)
if (opt_debug && rc) {
timeval_subtract(&diff, &tv_end, &tv_start);
applog(LOG_DEBUG, "DEBUG: got new work in %u µs",
diff.tv_sec * 1000000 + diff.tv_usec);
/* anime : {"error":null,"result":{
"target": "0000000000000000000000000000000000000000000000000000331a07000000",
"midstate":"57049c1d01d724567a1eb1886c5142cb79e7048f2ef206bee32441a90f3ec49e",
"hash1":"00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000",
"data":"000000701bfd5bf1745a10bde7cab641e90b196146410b2b28d60d57b90f0b3d0000000454b7169957e174da9575c67bc4da6ba9d204ca04c8ff5ef05cb06c2cd38e92065427a8331d071a3300000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000"},
"id":0} */
applog(LOG_DEBUG, "got new work %s", work->job_id);
}
json_decref(val);
@ -1459,7 +1475,7 @@ out: @@ -1459,7 +1475,7 @@ out:
return NULL;
}
#define PROGRAM_VERSION "1.4.4"
#define PROGRAM_VERSION "1.4.5"
static void show_version_and_exit(void)
{
printf("%s v%s\n"

6
cpuminer-config.h

@ -156,7 +156,7 @@ @@ -156,7 +156,7 @@
#define PACKAGE_NAME "ccminer"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "ccminer 2014.09.11"
#define PACKAGE_STRING "ccminer 2014.09.28"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "ccminer"
@ -165,7 +165,7 @@ @@ -165,7 +165,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "2014.09.11"
#define PACKAGE_VERSION "1.4"
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
@ -188,7 +188,7 @@ @@ -188,7 +188,7 @@
#define USE_XOP 1
/* Version number of package */
#define VERSION "2014.09.11"
#define VERSION "2014.09.28"
/* Define curl_free() as free() if our version of curl lacks curl_free. */
/* #undef curl_free */

3
miner.h

@ -352,7 +352,8 @@ extern uint16_t opt_vote; @@ -352,7 +352,8 @@ extern uint16_t opt_vote;
extern void applog(int prio, const char *fmt, ...);
extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
const char *rpc_req, bool, bool, int *);
extern char *bin2hex(const unsigned char *p, size_t len);
extern void cbin2hex(char *out, const char *in, size_t len);
extern char *bin2hex(const unsigned char *in, size_t len);
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
extern int timeval_subtract(struct timeval *result, struct timeval *x,
struct timeval *y);

27
quark/animecoin.cu

@ -140,7 +140,7 @@ extern "C" void animehash(void *state, const void *input) @@ -140,7 +140,7 @@ extern "C" void animehash(void *state, const void *input)
memcpy(state, hash, 32);
}
/*
struct HashPredicate
{
HashPredicate(uint32_t *hashes, uint32_t startNonce) :
@ -158,7 +158,7 @@ struct HashPredicate @@ -158,7 +158,7 @@ struct HashPredicate
uint32_t *m_hashes;
uint32_t m_startNonce;
};
*/
extern "C" int scanhash_anime(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, uint32_t max_nonce,
@ -170,7 +170,6 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata, @@ -170,7 +170,6 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata,
((uint32_t*)ptarget)[7] = 0x00000f;
const uint32_t Htarg = ptarget[7];
const int throughput = 256*2048; // 100;
static bool init[8] = {0,0,0,0,0,0,0,0};
@ -178,8 +177,7 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata, @@ -178,8 +177,7 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata,
{
cudaSetDevice(device_map[thr_id]);
// Konstanten kopieren, Speicher belegen
cudaMalloc(&d_hash[thr_id], 16 * sizeof(uint32_t) * throughput);
CUDA_SAFE_CALL(cudaMalloc(&d_hash[thr_id], 16 * sizeof(uint32_t) * throughput));
quark_blake512_cpu_init(thr_id, throughput);
quark_groestl512_cpu_init(thr_id, throughput);
@ -190,10 +188,10 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata, @@ -190,10 +188,10 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata,
cuda_check_cpu_init(thr_id, throughput);
quark_compactTest_cpu_init(thr_id, throughput);
cudaMalloc(&d_animeNonces[thr_id], sizeof(uint32_t)*throughput);
cudaMalloc(&d_branch1Nonces[thr_id], sizeof(uint32_t)*throughput);
cudaMalloc(&d_branch2Nonces[thr_id], sizeof(uint32_t)*throughput);
cudaMalloc(&d_branch3Nonces[thr_id], sizeof(uint32_t)*throughput);
CUDA_SAFE_CALL(cudaMalloc(&d_animeNonces[thr_id], sizeof(uint32_t)*throughput));
CUDA_SAFE_CALL(cudaMalloc(&d_branch1Nonces[thr_id], sizeof(uint32_t)*throughput));
CUDA_SAFE_CALL(cudaMalloc(&d_branch2Nonces[thr_id], sizeof(uint32_t)*throughput));
CUDA_SAFE_CALL(cudaMalloc(&d_branch3Nonces[thr_id], sizeof(uint32_t)*throughput));
init[thr_id] = true;
}
@ -269,17 +267,22 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata, @@ -269,17 +267,22 @@ extern "C" int scanhash_anime(int thr_id, uint32_t *pdata,
if ((vhash64[7]<=Htarg) && fulltest(vhash64, ptarget)) {
pdata[19] = foundNonce;
*hashes_done = (foundNonce - first_nonce + 1)/2;
*hashes_done = foundNonce - first_nonce + 1;
return 1;
} else {
applog(LOG_INFO, "GPU #%d: result for nonce $%08X does not validate on CPU!", thr_id, foundNonce);
}
}
if ((uint64_t)pdata[19] + throughput > (uint64_t)max_nonce) {
pdata[19] = max_nonce;
break;
}
pdata[19] += throughput;
} while (pdata[19] < max_nonce && !work_restart[thr_id].restart);
} while (!work_restart[thr_id].restart);
*hashes_done = (pdata[19] - first_nonce + 1)/2;
*hashes_done = pdata[19] - first_nonce + 1;
return 0;
}

25
util.c

@ -257,12 +257,12 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data) @@ -257,12 +257,12 @@ static size_t resp_hdr_cb(void *ptr, size_t size, size_t nmemb, void *user_data)
goto out;
if (!strcasecmp("X-Long-Polling", key)) {
hi->lp_path = val; /* steal memory reference */
hi->lp_path = val; /* X-Mining-Extensions: longpoll */
val = NULL;
}
if (!strcasecmp("X-Reject-Reason", key)) {
hi->reason = val; /* steal memory reference */
hi->reason = val; /* X-Mining-Extensions: reject-reason */
val = NULL;
}
@ -389,7 +389,7 @@ json_t *json_rpc_call(CURL *curl, const char *url, @@ -389,7 +389,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, len_hdr);
headers = curl_slist_append(headers, "User-Agent: " USER_AGENT);
headers = curl_slist_append(headers, "X-Mining-Extensions: midstate");
headers = curl_slist_append(headers, "X-Mining-Extensions: longpoll midstate reject-reason");
headers = curl_slist_append(headers, "Accept:"); /* disable Accept hdr*/
headers = curl_slist_append(headers, "Expect:"); /* disable Expect hdr*/
@ -433,7 +433,7 @@ json_t *json_rpc_call(CURL *curl, const char *url, @@ -433,7 +433,7 @@ json_t *json_rpc_call(CURL *curl, const char *url,
if (opt_protocol) {
char *s = json_dumps(val, JSON_INDENT(3));
applog(LOG_DEBUG, "JSON protocol response:\n%s", s);
applog(LOG_DEBUG, "JSON protocol response:\n%s\n", s);
free(s);
}
@ -476,15 +476,22 @@ err_out: @@ -476,15 +476,22 @@ err_out:
return NULL;
}
char *bin2hex(const unsigned char *p, size_t len)
void cbin2hex(char *out, const char *in, size_t len)
{
if (out) {
unsigned int i;
for (i = 0; i < len; i++)
sprintf(out + (i * 2), "%02x", (uint8_t)in[i]);
}
}
char *bin2hex(const unsigned char *in, size_t len)
{
unsigned int i;
char *s = (char*)malloc((len * 2) + 1);
if (!s)
return NULL;
for (i = 0; i < len; i++)
sprintf(s + (i * 2), "%02x", (unsigned int) p[i]);
cbin2hex(s, (const char *) in, len);
return s;
}
@ -1433,7 +1440,7 @@ extern void applog_compare_hash(unsigned char *hash, unsigned char *hash2) @@ -1433,7 +1440,7 @@ extern void applog_compare_hash(unsigned char *hash, unsigned char *hash2)
char s[256] = "";
int len = 0;
for (int i=0; i < 32; i += 4) {
char *color = memcmp(hash+i, hash2+i, 4) ? CL_RED : CL_GRY;
char *color = memcmp(hash+i, hash2+i, 4) ? CL_WHT : CL_GRY;
len += sprintf(s+len, "%s%02x%02x%02x%02x " CL_GRY, color,
hash[i], hash[i+1], hash[i+2], hash[i+3]);
s[len] = '\0';

Loading…
Cancel
Save