Path: blob/master/algo/myr-groestl.c
1313 views
#include "miner.h"12#include <stdio.h>3#include <stdlib.h>4#include <stdint.h>5#include <string.h>67#include "sha3/sph_groestl.h"8#include "sha3/sph_sha2.h"910void myriadhash(void *output, const void *input)11{12uint32_t _ALIGN(32) hash[16];13sph_groestl512_context ctx;14sph_sha256_context sha_ctx;1516// memset(&hash[0], 0, sizeof(hash));1718sph_groestl512_init(&ctx);19sph_groestl512(&ctx, input, 80);20sph_groestl512_close(&ctx, hash);2122sph_sha256_init(&sha_ctx);23sph_sha256(&sha_ctx, hash, 64);24sph_sha256_close(&sha_ctx, hash);2526memcpy(output, hash, 32);27}2829int scanhash_myriad(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)30{31uint32_t _ALIGN(128) hash[8];32uint32_t _ALIGN(128) endiandata[20];33uint32_t *pdata = work->data;34uint32_t *ptarget = work->target;3536const uint32_t Htarg = ptarget[7];37const uint32_t first_nonce = pdata[19];38uint32_t nonce = first_nonce;3940if (opt_benchmark)41ptarget[7] = 0x0000ff;4243for (int i=0; i < 19; i++) {44be32enc(&endiandata[i], pdata[i]);45}4647do {48be32enc(&endiandata[19], nonce);49myriadhash(hash, endiandata);5051if (hash[7] <= Htarg && fulltest(hash, ptarget)) {52work_set_target_ratio(work, hash);53pdata[19] = nonce;54*hashes_done = pdata[19] - first_nonce;55return 1;56}57nonce++;5859} while (nonce < max_nonce && !work_restart[thr_id].restart);6061pdata[19] = nonce;62*hashes_done = pdata[19] - first_nonce + 1;63return 0;64}656667