mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Use flip helpers to simplify code for calculation of midstate.
This commit is contained in:
parent
f50ae46850
commit
c351f8d8d3
20
cgminer.c
20
cgminer.c
@ -1473,22 +1473,16 @@ static bool jobj_binary(const json_t *obj, const char *key,
|
|||||||
|
|
||||||
static void calc_midstate(struct work *work)
|
static void calc_midstate(struct work *work)
|
||||||
{
|
{
|
||||||
union {
|
unsigned char data[64];
|
||||||
unsigned char c[64];
|
uint32_t *data32 = (uint32_t *)data;
|
||||||
uint32_t i[16];
|
|
||||||
} data;
|
|
||||||
int swapcounter;
|
|
||||||
|
|
||||||
for (swapcounter = 0; swapcounter < 16; swapcounter++)
|
|
||||||
data.i[swapcounter] = swab32(((uint32_t*) (work->data))[swapcounter]);
|
|
||||||
sha2_context ctx;
|
sha2_context ctx;
|
||||||
|
|
||||||
|
flip64(data32, work->data);
|
||||||
sha2_starts(&ctx);
|
sha2_starts(&ctx);
|
||||||
sha2_update(&ctx, data.c, 64);
|
sha2_update(&ctx, data, 64);
|
||||||
memcpy(work->midstate, ctx.state, sizeof(work->midstate));
|
memcpy(work->midstate, ctx.state, 32);
|
||||||
#if defined(__BIG_ENDIAN__) || defined(MIPSEB)
|
#if defined(__BIG_ENDIAN__) || defined(MIPSEB)
|
||||||
int i;
|
flip32(work->midstate, work->midstate);
|
||||||
for (i = 0; i < 8; i++)
|
|
||||||
(((uint32_t*) (work->midstate))[i]) = swab32(((uint32_t*) (work->midstate))[i]);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
miner.h
10
miner.h
@ -640,6 +640,16 @@ static inline void flip32(void *dest_p, const void *src_p)
|
|||||||
dest[i] = swab32(src[i]);
|
dest[i] = swab32(src[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void flip64(void *dest_p, const void *src_p)
|
||||||
|
{
|
||||||
|
uint32_t *dest = dest_p;
|
||||||
|
const uint32_t *src = src_p;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < 16; i++)
|
||||||
|
dest[i] = swab32(src[i]);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void flip80(void *dest_p, const void *src_p)
|
static inline void flip80(void *dest_p, const void *src_p)
|
||||||
{
|
{
|
||||||
uint32_t *dest = dest_p;
|
uint32_t *dest = dest_p;
|
||||||
|
Loading…
Reference in New Issue
Block a user