mirror of
https://github.com/xmrig/xmrig.git
synced 2025-01-03 17:40:13 +00:00
Pass blob size to cryptonight_hash_ctx.
This commit is contained in:
parent
54cef68aa9
commit
97a8d448c0
8 changed files with 24 additions and 24 deletions
|
@ -40,7 +40,6 @@ struct cryptonight_ctx {
|
|||
extern void (* const extra_hashes[4])(const void *, size_t, char *);
|
||||
|
||||
bool cryptonight_init(int variant);
|
||||
void cryptonight_hash(void* output, const void* input, size_t input_len);
|
||||
int scanhash_cryptonight(int thr_id, uint32_t *hash, uint32_t *restrict pdata, uint32_t target, uint32_t max_nonce, unsigned long *restrict hashes_done, struct cryptonight_ctx *restrict ctx);
|
||||
int scanhash_cryptonight(int thr_id, uint32_t *hash, uint32_t *restrict blob, size_t blob_size, uint32_t target, uint32_t max_nonce, unsigned long *restrict hashes_done, struct cryptonight_ctx *restrict ctx);
|
||||
|
||||
#endif /* __CRYPTONIGHT_H__ */
|
||||
|
|
|
@ -222,9 +222,9 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output)
|
|||
}
|
||||
|
||||
|
||||
void cryptonight_av1_aesni(void *restrict output, const void *restrict input, struct cryptonight_ctx *restrict ctx)
|
||||
void cryptonight_av1_aesni(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx)
|
||||
{
|
||||
keccak((const uint8_t *) input, 76, ctx->state, 200);
|
||||
keccak((const uint8_t *) input, size, ctx->state, 200);
|
||||
|
||||
cn_explode_scratchpad((__m128i*) ctx->state, (__m128i*) ctx->memory);
|
||||
|
||||
|
|
|
@ -222,9 +222,9 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output)
|
|||
}
|
||||
|
||||
|
||||
void cryptonight_av2_aesni_stak(void *restrict output, const void *restrict input, struct cryptonight_ctx *restrict ctx)
|
||||
void cryptonight_av2_aesni_stak(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx)
|
||||
{
|
||||
keccak((const uint8_t *) input, 76, ctx->state, 200);
|
||||
keccak((const uint8_t *) input, size, ctx->state, 200);
|
||||
|
||||
cn_explode_scratchpad((__m128i*) ctx->state, (__m128i*) ctx->memory);
|
||||
|
||||
|
|
|
@ -213,9 +213,9 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output)
|
|||
}
|
||||
|
||||
|
||||
void cryptonight_av3_aesni_bmi2(void *restrict output, const void *restrict input, struct cryptonight_ctx *restrict ctx)
|
||||
void cryptonight_av3_aesni_bmi2(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx)
|
||||
{
|
||||
keccak((const uint8_t *) input, 76, ctx->state, 200);
|
||||
keccak((const uint8_t *) input, size, ctx->state, 200);
|
||||
|
||||
cn_explode_scratchpad((__m128i*) ctx->state, (__m128i*) ctx->memory);
|
||||
|
||||
|
|
|
@ -203,9 +203,9 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output)
|
|||
}
|
||||
|
||||
|
||||
void cryptonight_av4_softaes(void *restrict output, const void *restrict input, struct cryptonight_ctx *restrict ctx)
|
||||
void cryptonight_av4_softaes(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx)
|
||||
{
|
||||
keccak((const uint8_t *) input, 76, ctx->state, 200);
|
||||
keccak((const uint8_t *) input, size, ctx->state, 200);
|
||||
|
||||
cn_explode_scratchpad((__m128i*) ctx->state, (__m128i*) ctx->memory);
|
||||
|
||||
|
|
|
@ -213,11 +213,11 @@ static inline void cn_implode_scratchpad(const __m128i* input, __m128i* output)
|
|||
}
|
||||
|
||||
|
||||
void cryptonight_av5_aesni_experimental(void *restrict output, const void *restrict input, struct cryptonight_ctx *restrict ctx)
|
||||
void cryptonight_av5_aesni_experimental(const void *restrict input, size_t size, void *restrict output, struct cryptonight_ctx *restrict ctx)
|
||||
{
|
||||
const uint8_t* memory = ctx->memory;
|
||||
|
||||
keccak((const uint8_t *) input, 76, ctx->state, 200);
|
||||
keccak((const uint8_t *) input, size, ctx->state, 200);
|
||||
cn_explode_scratchpad((__m128i*) ctx->state, (__m128i*) memory);
|
||||
|
||||
uint64_t* state = (uint64_t*) ctx->state;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef BUILD_TEST
|
||||
# include "xmrig.h"
|
||||
|
@ -52,16 +53,16 @@ const static char test_output[32] = {
|
|||
};
|
||||
|
||||
|
||||
void cryptonight_av1_aesni(void* output, const void* input, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av4_softaes(void* output, const void* input, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av1_aesni(void* input, size_t size, const void* output, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av4_softaes(void* input, size_t size, const void* output, struct cryptonight_ctx* ctx);
|
||||
|
||||
#if defined(__x86_64__)
|
||||
void cryptonight_av2_aesni_stak(void* output, const void* input, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av3_aesni_bmi2(void* output, const void* input, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av5_aesni_experimental(void* output, const void* input, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av2_aesni_stak(void* input, size_t size, const void* output, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av3_aesni_bmi2(void* input, size_t size, const void* output, struct cryptonight_ctx* ctx);
|
||||
void cryptonight_av5_aesni_experimental(void* input, size_t size, const void* output, struct cryptonight_ctx* ctx);
|
||||
#endif
|
||||
|
||||
void (*cryptonight_hash_ctx)(void* output, const void* input, struct cryptonight_ctx* ctx) = NULL;
|
||||
void (*cryptonight_hash_ctx)(void* input, size_t size, const void* output, struct cryptonight_ctx* ctx) = NULL;
|
||||
|
||||
|
||||
static bool self_test() {
|
||||
|
@ -70,7 +71,7 @@ static bool self_test() {
|
|||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*) malloc(sizeof(struct cryptonight_ctx));
|
||||
ctx->memory = (uint8_t *) malloc(MEMORY);
|
||||
|
||||
cryptonight_hash_ctx(output, test_input, ctx);
|
||||
cryptonight_hash_ctx(test_input, sizeof(test_input), output, ctx);
|
||||
|
||||
free(ctx->memory);
|
||||
free(ctx);
|
||||
|
@ -136,14 +137,14 @@ void (* const extra_hashes[4])(const void *, size_t, char *) = {do_blake_hash, d
|
|||
|
||||
|
||||
#ifndef BUILD_TEST
|
||||
int scanhash_cryptonight(int thr_id, uint32_t *hash, uint32_t *restrict pdata, uint32_t target, uint32_t max_nonce, unsigned long *restrict hashes_done, struct cryptonight_ctx *restrict ctx) {
|
||||
uint32_t *nonceptr = (uint32_t*) (((char*)pdata) + 39);
|
||||
int scanhash_cryptonight(int thr_id, uint32_t *hash, uint32_t *restrict blob, size_t blob_size, uint32_t target, uint32_t max_nonce, unsigned long *restrict hashes_done, struct cryptonight_ctx *restrict ctx) {
|
||||
uint32_t *nonceptr = (uint32_t*) (((char*) blob) + 39);
|
||||
uint32_t n = *nonceptr - 1;
|
||||
const uint32_t first_nonce = n + 1;
|
||||
|
||||
do {
|
||||
*nonceptr = ++n;
|
||||
cryptonight_hash_ctx(hash, pdata, ctx);
|
||||
cryptonight_hash_ctx(blob, blob_size, hash, ctx);
|
||||
|
||||
if (unlikely(hash[7] < target)) {
|
||||
*hashes_done = n - first_nonce + 1;
|
||||
|
|
2
xmrig.c
2
xmrig.c
|
@ -323,7 +323,7 @@ static void *miner_thread(void *userdata) {
|
|||
gettimeofday(&tv_start, NULL );
|
||||
|
||||
/* scan nonces for a proof-of-work hash */
|
||||
rc = scanhash_cryptonight(thr_id, hash, work.blob, work.target, max_nonce, &hashes_done, persistentctx);
|
||||
rc = scanhash_cryptonight(thr_id, hash, work.blob, work.blob_size, work.target, max_nonce, &hashes_done, persistentctx);
|
||||
stats_add_hashes(thr_id, &tv_start, hashes_done);
|
||||
|
||||
memcpy(work.hash, hash, 32);
|
||||
|
|
Loading…
Reference in a new issue