1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-11 07:17:58 +00:00

Hash1 is only used by the deprecated cpu mining code and never changes so remove it from the work struct and bypass needing to process the value for all other mining.

This commit is contained in:
Con Kolivas 2012-11-11 09:51:37 +11:00
parent f1f6b31faf
commit 598ee76d37
3 changed files with 9 additions and 15 deletions

View File

@ -111,7 +111,7 @@ int gpu_threads;
bool opt_scrypt;
#endif
#endif
bool opt_restart = true;
bool opt_restart;
static bool opt_nogpu;
struct list_head scan_devices;
@ -1498,7 +1498,6 @@ static void gen_gbt_work(struct pool *pool, struct work *work)
memset(work->data + 4 + 32 + 32 + 4 + 4, 0, 4); /* nonce */
hex2bin(work->data + 4 + 32 + 32 + 4 + 4 + 4, "000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000", 48);
hex2bin(work->hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000", 64);
if (opt_debug) {
char *header = bin2hex(work->data, 128);
@ -1597,11 +1596,6 @@ static bool getwork_decode(json_t *res_val, struct work *work)
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;
@ -5101,8 +5095,8 @@ static void set_work_target(struct work *work, int diff)
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;
int len, cb1_len, n1_len, cb2_len, i;
char header[260], *nonce2;
uint32_t *data32, *swap32;
memset(work->job_id, 0, 64);
@ -5171,9 +5165,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);

View File

@ -226,6 +226,7 @@ double bench_algo_stage3(
// Use a random work block pulled from a pool
static uint8_t bench_block[] = { CGMINER_BENCHMARK_BLOCK };
struct work work __attribute__((aligned(128)));
unsigned char hash1[64];
size_t bench_size = sizeof(work);
size_t work_size = sizeof(bench_block);
@ -240,6 +241,8 @@ double bench_algo_stage3(
uint32_t max_nonce = (1<<22);
uint32_t last_nonce = 0;
hex2bin(hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000", 64);
gettimeofday(&start, 0);
{
sha256_func func = sha256_funcs[algo];
@ -247,7 +250,7 @@ double bench_algo_stage3(
&dummy,
work.midstate,
work.data,
work.hash1,
hash1,
work.hash,
work.target,
max_nonce,
@ -799,11 +802,12 @@ static bool cpu_thread_init(struct thr_info *thr)
static int64_t cpu_scanhash(struct thr_info *thr, struct work *work, int64_t max_nonce)
{
const int thr_id = thr->id;
unsigned char hash1[64];
uint32_t first_nonce = work->blk.nonce;
uint32_t last_nonce;
bool rc;
hex2bin(hash1, "00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000", 64);
CPUSearch:
last_nonce = first_nonce;
rc = false;
@ -815,7 +819,7 @@ CPUSearch:
thr,
work->midstate,
work->data,
work->hash1,
hash1,
work->hash,
work->target,
max_nonce,

View File

@ -935,7 +935,6 @@ struct pool {
struct work {
unsigned char data[128];
unsigned char hash1[64];
unsigned char midstate[32];
unsigned char target[32];
unsigned char hash[32];