This commit is contained in:
Jay D Dee
2017-02-28 17:15:39 -05:00
parent f7865ae9f9
commit 1b288b1209
39 changed files with 259 additions and 258 deletions

View File

@@ -21,7 +21,7 @@ void blakehash(void *state, const void *input)
{
sph_blake256_context ctx;
uint8_t hash[64];
uint8_t hash[64] __attribute__ ((aligned (32)));
uint8_t *ending = (uint8_t*) input;
ending += 64;

View File

@@ -10,6 +10,7 @@
#include "algo/blake/sph_blake2b.h"
static __thread sph_blake2b_ctx s_midstate;
static __thread sph_blake2b_ctx s_ctx;
#define MIDLEN 76
@@ -18,7 +19,7 @@ static __thread sph_blake2b_ctx s_ctx;
void blake2b_hash(void *output, const void *input)
{
uint8_t _ALIGN(A) hash[32];
sph_blake2b_ctx ctx;
sph_blake2b_ctx ctx __attribute__ ((aligned (64)));
sph_blake2b_init(&ctx, 32, NULL, 0);
sph_blake2b_update(&ctx, input, 80);
@@ -129,6 +130,8 @@ void blake2b_be_build_stratum_request( char *req, struct work *work )
free( xnonce2str );
}
#define min(a,b) (a>b ? (b) :(a))
// merkle root handled here, no need for gen_merkle_root gate target
void blake2b_build_extraheader( struct work* g_work, struct stratum_ctx* sctx )
{
@@ -161,6 +164,8 @@ void blake2b_build_extraheader( struct work* g_work, struct stratum_ctx* sctx )
g_work->data[12+i] = ( (uint32_t*)merkle_root )[i];
}
#undef min
void blake2b_get_new_work( struct work* work, struct work* g_work, int thr_id,
uint32_t* end_nonce_ptr, bool clean_job )
{

View File

@@ -13,7 +13,7 @@ static __thread blake2s_state s_ctx;
void blake2s_hash(void *output, const void *input)
{
unsigned char _ALIGN(64) hash[BLAKE2S_OUTBYTES];
blake2s_state blake2_ctx;
blake2s_state blake2_ctx __attribute__ ((aligned (64)));
blake2s_init(&blake2_ctx, BLAKE2S_OUTBYTES);
blake2s_update(&blake2_ctx, input, 80);

View File

@@ -30,7 +30,7 @@ static void blake_midstate_init( const void* input )
void blakecoinhash( void *state, const void *input )
{
sph_blake256_context ctx;
uint8_t hash[64];
uint8_t hash[64] __attribute__ ((aligned (32)));
uint8_t *ending = (uint8_t*) input + 64;
// copy cached midstate

View File

@@ -27,7 +27,7 @@ static __thread bool ctx_midstate_done = false;
void decred_hash(void *state, const void *input)
{
#define MIDSTATE_LEN 128
sph_blake256_context ctx;
sph_blake256_context ctx __attribute__ ((aligned (64)));
uint8_t *ending = (uint8_t*) input;
ending += MIDSTATE_LEN;
@@ -53,8 +53,8 @@ void decred_hash_simple(void *state, const void *input)
int scanhash_decred(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t _ALIGN(128) endiandata[48];
uint32_t _ALIGN(128) hash32[8];
uint32_t _ALIGN(64) endiandata[48];
uint32_t _ALIGN(64) hash32[8];
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
@@ -194,6 +194,10 @@ void decred_gen_merkle_root( char* merkle_root, struct stratum_ctx* sctx )
memcpy( decred_extraheader, &sctx->job.coinbase[32], decred_headersize);
}
*/
#define min(a,b) (a>b ? (b) :(a))
void decred_build_extraheader( struct work* g_work, struct stratum_ctx* sctx )
{
uchar merkle_root[64] = { 0 };
@@ -239,20 +243,7 @@ void decred_build_extraheader( struct work* g_work, struct stratum_ctx* sctx )
//applog_hex(&work->data[36], 36);
}
/*
bool decred_prevent_dupes( struct work* work, struct stratum_ctx* stratum,
int thr_id )
{
return false;
if ( have_stratum && strcmp(stratum->job.job_id, work->job_id) )
// need to regen g_work..
return true;
// extradata: prevent duplicates
work->data[ DECRED_XNONCE_INDEX ] += 1;
work->data[ DECRED_XNONCE_INDEX + 1 ] |= thr_id;
return false;
}
*/
#undef min
bool decred_ready_to_mine( struct work* work, struct stratum_ctx* stratum,
int thr_id )
@@ -282,9 +273,7 @@ bool register_decred_algo( algo_gate_t* gate )
gate->get_max64 = (void*)&get_max64_0x3fffffLL;
gate->display_extra_data = (void*)&decred_decode_extradata;
gate->build_stratum_request = (void*)&decred_be_build_stratum_request;
// gate->gen_merkle_root = (void*)&decred_gen_merkle_root;
gate->build_extraheader = (void*)&decred_build_extraheader;
// gate->prevent_dupes = (void*)&decred_prevent_dupes;
gate->ready_to_mine = (void*)&decred_ready_to_mine;
gate->nbits_index = DECRED_NBITS_INDEX;
gate->ntime_index = DECRED_NTIME_INDEX;