mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-23 13:04:29 +00:00
Calculate midstate in separate function and remove likely/unlikely macros since they're dependent on pools, not code design.
This commit is contained in:
parent
8230ab0549
commit
41daf99537
27
cgminer.c
27
cgminer.c
@ -1230,22 +1230,14 @@ static bool jobj_binary(const json_t *obj, const char *key,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool work_decode(const json_t *val, struct work *work)
|
static void calc_midstate(struct work *work)
|
||||||
{
|
{
|
||||||
if (unlikely(!jobj_binary(val, "data", work->data, sizeof(work->data), true))) {
|
|
||||||
applog(LOG_ERR, "JSON inval data");
|
|
||||||
goto err_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (likely(!jobj_binary(val, "midstate",
|
|
||||||
work->midstate, sizeof(work->midstate), false))) {
|
|
||||||
applog(LOG_DEBUG, "Calculating midstate locally");
|
|
||||||
// Calculate it ourselves
|
|
||||||
union {
|
union {
|
||||||
unsigned char c[64];
|
unsigned char c[64];
|
||||||
uint32_t i[16];
|
uint32_t i[16];
|
||||||
} data;
|
} data;
|
||||||
int swapcounter;
|
int swapcounter;
|
||||||
|
|
||||||
for (swapcounter = 0; swapcounter < 16; swapcounter++)
|
for (swapcounter = 0; swapcounter < 16; swapcounter++)
|
||||||
data.i[swapcounter] = swab32(((uint32_t*) (work->data))[swapcounter]);
|
data.i[swapcounter] = swab32(((uint32_t*) (work->data))[swapcounter]);
|
||||||
sha2_context ctx;
|
sha2_context ctx;
|
||||||
@ -1257,9 +1249,22 @@ static bool work_decode(const json_t *val, struct work *work)
|
|||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
(((uint32_t*) (work->midstate))[i]) = swab32(((uint32_t*) (work->midstate))[i]);
|
(((uint32_t*) (work->midstate))[i]) = swab32(((uint32_t*) (work->midstate))[i]);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool work_decode(const json_t *val, struct work *work)
|
||||||
|
{
|
||||||
|
if (unlikely(!jobj_binary(val, "data", work->data, sizeof(work->data), true))) {
|
||||||
|
applog(LOG_ERR, "JSON inval data");
|
||||||
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (likely(!jobj_binary(val, "hash1", work->hash1, sizeof(work->hash1), false))) {
|
if (!jobj_binary(val, "midstate", work->midstate, sizeof(work->midstate), false)) {
|
||||||
|
// Calculate it ourselves
|
||||||
|
applog(LOG_DEBUG, "Calculating midstate locally");
|
||||||
|
calc_midstate(work);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!jobj_binary(val, "hash1", work->hash1, sizeof(work->hash1), false)) {
|
||||||
// Always the same anyway
|
// 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);
|
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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user