mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
add drop algo, and hash debug flag
This commit is contained in:
parent
9e40da9ef2
commit
f249ec0140
12 changed files with 480 additions and 39 deletions
1
rc.local
1
rc.local
|
@ -27,6 +27,7 @@ screen -dmS quark /var/stratum/run.sh quark
|
|||
#screen -dmS qubit /var/stratum/run.sh qubit
|
||||
screen -dmS lyra2 /var/stratum/run.sh lyra2
|
||||
screen -dmS zr5 /var/stratum/run.sh zr5
|
||||
screen -dmS drop /var/stratum/run.sh drop
|
||||
|
||||
# exit 0
|
||||
|
||||
|
|
|
@ -4,6 +4,12 @@ CC=gcc
|
|||
CFLAGS=-c -g -I /usr/include/mysql -march=native
|
||||
LDFLAGS=-g
|
||||
|
||||
#CFLAGS += -DHASH_DEBUGLOG_
|
||||
#CFLAGS += -DRPC_DEBUGLOG_
|
||||
#CFLAGS += -DREMOTE_DEBUGLOG_
|
||||
#CFLAGS += -DSOCKET_DEBUGLOG_
|
||||
#CFLAGS += -DCLIENT_DEBUGLOG_
|
||||
|
||||
#CFLAGS=-c -O2 -I /usr/include/mysql
|
||||
#LDFLAGS=-O2
|
||||
|
||||
|
|
408
stratum/algos/drop.c
Normal file
408
stratum/algos/drop.c
Normal file
|
@ -0,0 +1,408 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "drop.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../sha3/sph_blake.h"
|
||||
#include "../sha3/sph_groestl.h"
|
||||
#include "../sha3/sph_skein.h"
|
||||
#include "../sha3/sph_jh.h"
|
||||
#include "../sha3/sph_keccak.h"
|
||||
#include "../sha3/sph_luffa.h"
|
||||
#include "../sha3/sph_cubehash.h"
|
||||
#include "../sha3/sph_shavite.h"
|
||||
#include "../sha3/sph_simd.h"
|
||||
#include "../sha3/sph_echo.h"
|
||||
#include "../sha3/sph_fugue.h"
|
||||
|
||||
//#define TEST_VERBOSELY
|
||||
|
||||
static inline void shiftr_lp(const uint32_t *input, uint32_t *output, unsigned int shift)
|
||||
{
|
||||
if (!shift) {
|
||||
memcpy(output, input, 64);
|
||||
return;
|
||||
}
|
||||
memset(output, 0, 64);
|
||||
int i;
|
||||
for (i = 0; i < 15; ++i) {
|
||||
output[i + 1] |= (input[i] >> (32 - shift));
|
||||
output[i] |= (input[i] << shift);
|
||||
}
|
||||
output[15] |= (input[15] << shift);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void drop_hash_512( uint8_t* input, uint8_t* output, uint32_t len )
|
||||
{
|
||||
uint8_t hash[2][64];
|
||||
|
||||
sph_jh512_context ctx_jh;
|
||||
sph_keccak512_context ctx_keccak;
|
||||
sph_blake512_context ctx_blake;
|
||||
sph_groestl512_context ctx_groestl;
|
||||
sph_skein512_context ctx_skein;
|
||||
sph_luffa512_context ctx_luffa;
|
||||
sph_echo512_context ctx_echo;
|
||||
sph_shavite512_context ctx_shavite;
|
||||
sph_fugue512_context ctx_fugue;
|
||||
sph_simd512_context ctx_simd;
|
||||
sph_cubehash512_context ctx_cubehash;
|
||||
|
||||
unsigned int startPosition; // order in which to apply the hashing algos
|
||||
unsigned int i = 0;
|
||||
unsigned int j = 0;
|
||||
|
||||
uint8_t *phashA = (uint8_t *)(&hash[0]);
|
||||
uint8_t *phashB = (uint8_t *)(&hash[1]);
|
||||
|
||||
// initialize the buffers for hash results
|
||||
for(i=0; i<2; i++) { for(j=0; j<64; j++) { hash[i][j] = 0; } }
|
||||
|
||||
|
||||
sph_jh512_init(&ctx_jh);
|
||||
sph_jh512 (&ctx_jh, input, len);
|
||||
sph_jh512_close(&ctx_jh, phashA);
|
||||
|
||||
uint32_t gls32 = getleastsig32(phashA, 0);
|
||||
startPosition = gls32 % 31;
|
||||
|
||||
for (i = startPosition; i < 31; i--) {
|
||||
int start = i % 10;
|
||||
for ( j = start; j < 10; j++) {
|
||||
shiftr_lp((uint32_t *)phashA, (uint32_t *)phashB, (i & 3));
|
||||
switch (j) {
|
||||
case 0:
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512(&ctx_keccak, phashB, 64);
|
||||
sph_keccak512_close(&ctx_keccak, phashA);
|
||||
break;
|
||||
case 1:
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512(&ctx_blake, phashB, 64);
|
||||
sph_blake512_close(&ctx_blake, phashA);
|
||||
break;
|
||||
case 2:
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512(&ctx_groestl, phashB, 64);
|
||||
sph_groestl512_close(&ctx_groestl, phashA);
|
||||
break;
|
||||
case 3:
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512(&ctx_skein, phashB, 64);
|
||||
sph_skein512_close(&ctx_skein, phashA);
|
||||
break;
|
||||
case 4:
|
||||
sph_luffa512_init(&ctx_luffa);
|
||||
sph_luffa512(&ctx_luffa, phashB, 64);
|
||||
sph_luffa512_close(&ctx_luffa, phashA);
|
||||
break;
|
||||
case 5:
|
||||
sph_echo512_init(&ctx_echo);
|
||||
sph_echo512(&ctx_echo, phashB, 64);
|
||||
sph_echo512_close(&ctx_echo, phashA);
|
||||
break;
|
||||
case 6:
|
||||
sph_shavite512_init(&ctx_shavite);
|
||||
sph_shavite512(&ctx_shavite, phashB, 64);
|
||||
sph_shavite512_close(&ctx_shavite, phashA);
|
||||
break;
|
||||
case 7:
|
||||
sph_fugue512_init(&ctx_fugue);
|
||||
sph_fugue512(&ctx_fugue, phashB, 64);
|
||||
sph_fugue512_close(&ctx_fugue, phashA);
|
||||
break;
|
||||
case 8:
|
||||
sph_simd512_init(&ctx_simd);
|
||||
sph_simd512(&ctx_simd, phashB, 64);
|
||||
sph_simd512_close(&ctx_simd, phashA);
|
||||
break;
|
||||
case 9:
|
||||
sph_cubehash512_init(&ctx_cubehash);
|
||||
sph_cubehash512(&ctx_cubehash, phashB, 64);
|
||||
sph_cubehash512_close(&ctx_cubehash, phashA);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( j = 0; j < start; j++) {
|
||||
shiftr_lp((uint32_t *)phashA, (uint32_t *)phashB, (i & 3));
|
||||
switch (j) {
|
||||
case 0:
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512(&ctx_keccak, phashB, 64);
|
||||
sph_keccak512_close(&ctx_keccak, phashA);
|
||||
break;
|
||||
case 1:
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512(&ctx_blake, phashB, 64);
|
||||
sph_blake512_close(&ctx_blake, phashA);
|
||||
break;
|
||||
case 2:
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512(&ctx_groestl, phashB, 64);
|
||||
sph_groestl512_close(&ctx_groestl, phashA);
|
||||
break;
|
||||
case 3:
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512(&ctx_skein, phashB, 64);
|
||||
sph_skein512_close(&ctx_skein, phashA);
|
||||
break;
|
||||
case 4:
|
||||
sph_luffa512_init(&ctx_luffa);
|
||||
sph_luffa512(&ctx_luffa, phashB, 64);
|
||||
sph_luffa512_close(&ctx_luffa, phashA);
|
||||
break;
|
||||
case 5:
|
||||
sph_echo512_init(&ctx_echo);
|
||||
sph_echo512(&ctx_echo, phashB, 64);
|
||||
sph_echo512_close(&ctx_echo, phashA);
|
||||
break;
|
||||
case 6:
|
||||
sph_shavite512_init(&ctx_shavite);
|
||||
sph_shavite512(&ctx_shavite, phashB, 64);
|
||||
sph_shavite512_close(&ctx_shavite, phashA);
|
||||
break;
|
||||
case 7:
|
||||
sph_fugue512_init(&ctx_fugue);
|
||||
sph_fugue512(&ctx_fugue, phashB, 64);
|
||||
sph_fugue512_close(&ctx_fugue, phashA);
|
||||
break;
|
||||
case 8:
|
||||
sph_simd512_init(&ctx_simd);
|
||||
sph_simd512(&ctx_simd, phashB, 64);
|
||||
sph_simd512_close(&ctx_simd, phashA);
|
||||
break;
|
||||
case 9:
|
||||
sph_cubehash512_init(&ctx_cubehash);
|
||||
sph_cubehash512(&ctx_cubehash, phashB, 64);
|
||||
sph_cubehash512_close(&ctx_cubehash, phashA);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
i += 10;
|
||||
}
|
||||
for ( i = 0; i < startPosition; i--) {
|
||||
int start = i % 10;
|
||||
for ( j = start; j < 10; j++) {
|
||||
shiftr_lp((uint32_t *)phashA, (uint32_t *)phashB, (i & 3));
|
||||
switch (j) {
|
||||
case 0:
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512(&ctx_keccak, phashB, 64);
|
||||
sph_keccak512_close(&ctx_keccak, phashA);
|
||||
break;
|
||||
case 1:
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512(&ctx_blake, phashB, 64);
|
||||
sph_blake512_close(&ctx_blake, phashA);
|
||||
break;
|
||||
case 2:
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512(&ctx_groestl, phashB, 64);
|
||||
sph_groestl512_close(&ctx_groestl, phashA);
|
||||
break;
|
||||
case 3:
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512(&ctx_skein, phashB, 64);
|
||||
sph_skein512_close(&ctx_skein, phashA);
|
||||
break;
|
||||
case 4:
|
||||
sph_luffa512_init(&ctx_luffa);
|
||||
sph_luffa512(&ctx_luffa, phashB, 64);
|
||||
sph_luffa512_close(&ctx_luffa, phashA);
|
||||
break;
|
||||
case 5:
|
||||
sph_echo512_init(&ctx_echo);
|
||||
sph_echo512(&ctx_echo, phashB, 64);
|
||||
sph_echo512_close(&ctx_echo, phashA);
|
||||
break;
|
||||
case 6:
|
||||
sph_shavite512_init(&ctx_shavite);
|
||||
sph_shavite512(&ctx_shavite, phashB, 64);
|
||||
sph_shavite512_close(&ctx_shavite, phashA);
|
||||
break;
|
||||
case 7:
|
||||
sph_fugue512_init(&ctx_fugue);
|
||||
sph_fugue512(&ctx_fugue, phashB, 64);
|
||||
sph_fugue512_close(&ctx_fugue, phashA);
|
||||
break;
|
||||
case 8:
|
||||
sph_simd512_init(&ctx_simd);
|
||||
sph_simd512(&ctx_simd, phashB, 64);
|
||||
sph_simd512_close(&ctx_simd, phashA);
|
||||
break;
|
||||
case 9:
|
||||
sph_cubehash512_init(&ctx_cubehash);
|
||||
sph_cubehash512(&ctx_cubehash, phashB, 64);
|
||||
sph_cubehash512_close(&ctx_cubehash, phashA);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
for ( j = 0; j < start; j++) {
|
||||
shiftr_lp((uint32_t *)phashA, (uint32_t *)phashB, (i & 3));
|
||||
switch (j) {
|
||||
case 0:
|
||||
sph_keccak512_init(&ctx_keccak);
|
||||
sph_keccak512(&ctx_keccak, phashB, 64);
|
||||
sph_keccak512_close(&ctx_keccak, phashA);
|
||||
break;
|
||||
case 1:
|
||||
sph_blake512_init(&ctx_blake);
|
||||
sph_blake512(&ctx_blake, phashB, 64);
|
||||
sph_blake512_close(&ctx_blake, phashA);
|
||||
break;
|
||||
case 2:
|
||||
sph_groestl512_init(&ctx_groestl);
|
||||
sph_groestl512(&ctx_groestl, phashB, 64);
|
||||
sph_groestl512_close(&ctx_groestl, phashA);
|
||||
break;
|
||||
case 3:
|
||||
sph_skein512_init(&ctx_skein);
|
||||
sph_skein512(&ctx_skein, phashB, 64);
|
||||
sph_skein512_close(&ctx_skein, phashA);
|
||||
break;
|
||||
case 4:
|
||||
sph_luffa512_init(&ctx_luffa);
|
||||
sph_luffa512(&ctx_luffa, phashB, 64);
|
||||
sph_luffa512_close(&ctx_luffa, phashA);
|
||||
break;
|
||||
case 5:
|
||||
sph_echo512_init(&ctx_echo);
|
||||
sph_echo512(&ctx_echo, phashB, 64);
|
||||
sph_echo512_close(&ctx_echo, phashA);
|
||||
break;
|
||||
case 6:
|
||||
sph_shavite512_init(&ctx_shavite);
|
||||
sph_shavite512(&ctx_shavite, phashB, 64);
|
||||
sph_shavite512_close(&ctx_shavite, phashA);
|
||||
break;
|
||||
case 7:
|
||||
sph_fugue512_init(&ctx_fugue);
|
||||
sph_fugue512(&ctx_fugue, phashB, 64);
|
||||
sph_fugue512_close(&ctx_fugue, phashA);
|
||||
break;
|
||||
case 8:
|
||||
sph_simd512_init(&ctx_simd);
|
||||
sph_simd512(&ctx_simd, phashB, 64);
|
||||
sph_simd512_close(&ctx_simd, phashA);
|
||||
break;
|
||||
case 9:
|
||||
sph_cubehash512_init(&ctx_cubehash);
|
||||
sph_cubehash512(&ctx_cubehash, phashB, 64);
|
||||
sph_cubehash512_close(&ctx_cubehash, phashA);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
i += 10;
|
||||
}
|
||||
|
||||
phashB = (uint8_t *)output;
|
||||
for (i = 0; i < 64; i++) {
|
||||
phashB[i] = phashA[i];
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void drop_hash(const char* input, char* output, uint32_t len)
|
||||
{
|
||||
uint8_t *input512; // writeable copy of input
|
||||
uint8_t output512[64]; // output of both zr5 hashes
|
||||
uint32_t version; // writeable copy of version
|
||||
uint32_t nPoK = 0; // integer copy of PoK state
|
||||
static const unsigned int POK_BOOL_MASK = 0x00008000;
|
||||
static const unsigned int POK_DATA_MASK = 0xFFFF0000;
|
||||
#ifdef TEST_VERBOSELY
|
||||
char buffer[512] = { 0 };
|
||||
char *buf = buffer;
|
||||
uint32_t i = 0;
|
||||
#endif
|
||||
|
||||
// copy the input buffer at input to a modifiable location at input512,
|
||||
input512 = (uint8_t*)malloc(len); // allocate space for the copy
|
||||
memcpy((uint8_t*)input512, (uint8_t*)input, len);
|
||||
|
||||
#ifdef TEST_VERBOSELY
|
||||
fprintf(stderr, "drop_hash input: ");
|
||||
for (i=0; i<len; i++) sprintf(stderr, "%02x", input512[i]);
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
|
||||
// store the version bytes
|
||||
memcpy((uint8_t *)&version, (uint8_t *)input, 4);
|
||||
|
||||
// apply the first hash, yielding 512bits = 64 bytes
|
||||
drop_hash_512(input512, output512, len);
|
||||
|
||||
// Now begins Proof of Knowledge
|
||||
//
|
||||
// Pull the data from the result for the Proof of Knowledge
|
||||
// (this is the 3rd and 4th of the first four bytes of the result)
|
||||
memcpy(&nPoK, (uint8_t *)output512, 4); // yields big or little endian uint
|
||||
// keep only the two least significant bytes
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
nPoK &= 0xFFFF0000; // bytes 3&4 of big endian are 1&2 of little endian
|
||||
#else
|
||||
nPoK &= 0x0000FFFF; // bytes 1&2 of big endian are 3&4 of little endian
|
||||
#endif
|
||||
//
|
||||
// PoK part 2:
|
||||
// update the version variable with the masks and PoK value
|
||||
// according to the Proof of Knowledge setting
|
||||
version &= (~POK_BOOL_MASK);
|
||||
version |= (POK_DATA_MASK & nPoK);
|
||||
#ifdef TEST_VERBOSELY
|
||||
fprintf(stderr, "new version field: %x\n", version);
|
||||
#endif
|
||||
|
||||
// and now write it back out to our copy of the input buffer
|
||||
memcpy((uint8_t *)input512, (uint8_t *)&version, 4);
|
||||
|
||||
// apply a second ZR5 hash of the modified input, 512 bits in and out,
|
||||
// to the input modified with PoK. Length is still the original length
|
||||
drop_hash_512(input512, output512, len);
|
||||
|
||||
// copy the left-most 256 bits (32 bytes) of the last hash into the output buffer
|
||||
memcpy((uint8_t *)output, (uint8_t *)output512, sizeof(output512)/2);
|
||||
|
||||
#ifdef TEST_VERBOSELY
|
||||
buf += sprintf(buf, "drop hash: ");
|
||||
for (i=0; i<32; i++) { buf += sprintf(buf, "%02x", output512[i]); }
|
||||
fprintf(stderr, "%s\n", buffer); buf = buffer;
|
||||
#endif
|
||||
|
||||
free(input512);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// WARNING: This routine might work for little endian numbers!
|
||||
uint32_t getleastsig32( uint8_t* buffer, unsigned int nIndex)
|
||||
{
|
||||
uint32_t * ptr = NULL;
|
||||
uint32_t result;
|
||||
|
||||
ptr = (uint32_t *)buffer;
|
||||
result = ptr[nIndex % sizeof(uint32_t)];
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
24
stratum/algos/drop.h
Normal file
24
stratum/algos/drop.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef DROPLP_H
|
||||
#define DROPLP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define ARRAYLEN(array) (sizeof(array)/sizeof((array)[0]))
|
||||
#define WIDTH (BITS/32)
|
||||
static const unsigned int VERSION_MASK = 0x00007FFF;
|
||||
static const unsigned int POK_BOOL_MASK = 0x00008000;
|
||||
static const unsigned int POK_DATA_MASK = 0xFFFF0000;
|
||||
|
||||
void drop_hash(const char* input, char* output, uint32_t len );
|
||||
void drop_hash_512( uint8_t* input, uint8_t* output, uint32_t len );
|
||||
uint32_t getleastsig32( uint8_t* buffer, unsigned int nIndex );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -9,7 +9,7 @@ LDFLAGS=-O2
|
|||
|
||||
SOURCES=Lyra2RE.c Lyra2.c Sponge.c blake.c scrypt.c c11.c x11.c x13.c sha256.c keccak.c \
|
||||
x14.c x15.c nist5.c fresh.c quark.c neoscrypt.c scryptn.c qubit.c skein.c groestl.c \
|
||||
zr5.c
|
||||
zr5.c drop.c
|
||||
|
||||
OBJECTS=$(SOURCES:.c=.o)
|
||||
OUTPUT=libalgos.a
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
|
||||
#include "stratum.h"
|
||||
|
||||
//#define HASH_DEBUGLOG_
|
||||
//#define DONTSUBMIT
|
||||
|
||||
void build_submit_values(YAAMP_JOB_VALUES *submitvalues, YAAMP_JOB_TEMPLATE *templ,
|
||||
|
@ -142,12 +143,11 @@ void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VALUES *su
|
|||
block_add(client->userid, coind->id, templ->height, target_to_diff(coin_target), target_to_diff(hash_int),
|
||||
hash1, submitvalues->hash_be);
|
||||
|
||||
// if(!strcmp(coind->symbol, "HAL"))
|
||||
// {
|
||||
// debuglog("--------------------------------------------------------------\n");
|
||||
// debuglog("hash1 %s\n", hash1);
|
||||
// debuglog("hash2 %s\n", submitvalues->hash_be);
|
||||
// }
|
||||
#ifdef HASH_DEBUGLOG_
|
||||
debuglog("--------------------------------------------------------------\n");
|
||||
debuglog("hash1 %s\n", hash1);
|
||||
debuglog("hash2 %s\n", submitvalues->hash_be);
|
||||
#endif
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -176,7 +176,9 @@ void client_submit_error(YAAMP_CLIENT *client, YAAMP_JOB *job, int id, const cha
|
|||
share_add(client, job, false, extranonce2, ntime, nonce, id);
|
||||
|
||||
client->submit_bad++;
|
||||
// dump_submit_debug(message, client, job, extranonce2, ntime, nonce);
|
||||
#ifdef HASH_DEBUGLOG_
|
||||
dump_submit_debug(message, client, job, extranonce2, ntime, nonce);
|
||||
#endif
|
||||
}
|
||||
|
||||
object_unlock(job);
|
||||
|
@ -192,7 +194,6 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
|
|||
return false;
|
||||
}
|
||||
|
||||
// char name[1024];
|
||||
char extranonce2[32];
|
||||
char ntime[32];
|
||||
char nonce[32];
|
||||
|
@ -206,7 +207,9 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
|
|||
strncpy(ntime, json_params->u.array.values[3]->u.string.ptr, 31);
|
||||
strncpy(nonce, json_params->u.array.values[4]->u.string.ptr, 31);
|
||||
|
||||
// debuglog("submit %s %d, %s, %s, %s\n", client->sock->ip, jobid, extranonce2, ntime, nonce);
|
||||
#ifdef HASH_DEBUGLOG_
|
||||
debuglog("submit %s %d, %s, %s, %s\n", client->sock->ip, jobid, extranonce2, ntime, nonce);
|
||||
#endif
|
||||
|
||||
string_lower(extranonce2);
|
||||
string_lower(ntime);
|
||||
|
@ -228,7 +231,6 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
|
|||
}
|
||||
|
||||
YAAMP_JOB_TEMPLATE *templ = job->templ;
|
||||
// dump_submit_debug(client, job, extranonce2, ntime, nonce);
|
||||
|
||||
if(strlen(nonce) != YAAMP_NONCE_SIZE*2)
|
||||
{
|
||||
|
@ -271,10 +273,11 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
|
|||
uint64_t user_target = diff_to_target(client->difficulty_actual);
|
||||
uint64_t coin_target = decode_compact(templ->nbits);
|
||||
|
||||
// debuglog("%016llx actual\n", hash_int);
|
||||
// debuglog("%016llx target\n", user_target);
|
||||
// debuglog("%016llx coin\n", coin_target);
|
||||
|
||||
#ifdef HASH_DEBUGLOG_
|
||||
debuglog("%016llx actual\n", hash_int);
|
||||
debuglog("%016llx target\n", user_target);
|
||||
debuglog("%016llx coin\n", coin_target);
|
||||
#endif
|
||||
if(hash_int > user_target && hash_int > coin_target)
|
||||
{
|
||||
client_submit_error(client, job, 26, "Low difficulty share", extranonce2, ntime, nonce);
|
||||
|
@ -296,9 +299,3 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -87,8 +87,7 @@ YAAMP_JOB_TEMPLATE *coind_create_template_memorypool(YAAMP_COIND *coind)
|
|||
templ->height = json_get_int(json_result, "blocks")+1;
|
||||
json_value_free(json);
|
||||
|
||||
if(coind->isaux)
|
||||
coind_getauxblock(coind);
|
||||
coind_getauxblock(coind);
|
||||
|
||||
coind->usememorypool = true;
|
||||
return templ;
|
||||
|
@ -114,7 +113,7 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
json_value *json_result = json_get_object(json, "result");
|
||||
if(!json_result || json_result->type == json_null)
|
||||
{
|
||||
coind_error(coind, "getblocktemplate");
|
||||
coind_error(coind, "getblocktemplate result");
|
||||
json_value_free(json);
|
||||
|
||||
return NULL;
|
||||
|
@ -123,16 +122,16 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
json_value *json_tx = json_get_array(json_result, "transactions");
|
||||
if(!json_tx)
|
||||
{
|
||||
coind_error(coind, "getblocktemplate");
|
||||
coind_error(coind, "getblocktemplate transactions");
|
||||
json_value_free(json);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_value *json_coinbaseaux = json_get_object(json_result, "coinbaseaux");
|
||||
if(!json_coinbaseaux)
|
||||
if(!json_coinbaseaux && coind->isaux)
|
||||
{
|
||||
coind_error(coind, "getblocktemplate");
|
||||
coind_error(coind, "getblocktemplate coinbaseaux");
|
||||
json_value_free(json);
|
||||
|
||||
return NULL;
|
||||
|
@ -148,7 +147,9 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
sprintf(templ->ntime, "%08x", (unsigned int)json_get_int(json_result, "curtime"));
|
||||
strcpy(templ->nbits, json_get_string(json_result, "bits"));
|
||||
strcpy(templ->prevhash_hex, json_get_string(json_result, "previousblockhash"));
|
||||
strcpy(templ->flags, json_get_string(json_coinbaseaux, "flags"));
|
||||
|
||||
if (strcmp(coind->symbol, "DRP")) // not in Dropcoin
|
||||
strcpy(templ->flags, json_get_string(json_coinbaseaux, "flags"));
|
||||
|
||||
// debuglog("%s ntime %s\n", coind->symbol, templ->ntime);
|
||||
// uint64_t target = decode_compact(json_get_string(json_result, "bits"));
|
||||
|
@ -167,7 +168,6 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
if(coind->isaux)
|
||||
{
|
||||
json_value_free(json);
|
||||
|
||||
coind_getauxblock(coind);
|
||||
return templ;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,9 @@ YAAMP_ALGO g_algos[] =
|
|||
{"skein", skein_hash, 1, 0, 0},
|
||||
{"keccak", keccak_hash, 1, 0, 0},
|
||||
|
||||
{"zr5", zr5_hash, 0x10000, 0, 0},
|
||||
{"zr5", zr5_hash, 1, 0, 0},
|
||||
{"drop", drop_hash, 0x10000, 0x10000, 0},
|
||||
|
||||
// {"whirlpoolx", whirlpoolx_hash, 1, 0, 0},
|
||||
// {"jha", jha_hash, 1, 0, 0},
|
||||
// {"m7", NULL, 1, 0},
|
||||
|
@ -317,6 +319,3 @@ void *stratum_thread(void *p)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -136,6 +136,7 @@ void sha256_double_hash_hex(const char *input, char *output, unsigned int len);
|
|||
|
||||
//#include "algos/whirlpoolx.h"
|
||||
#include "algos/zr5.h"
|
||||
#include "algos/drop.h"
|
||||
//#include "jha.h"
|
||||
//#include "hash/m7m.h"
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ function BackendUpdateServices()
|
|||
|
||||
111=>'c11',
|
||||
112=>'zr5',
|
||||
113=>'drop',
|
||||
);
|
||||
|
||||
$res = fetch_url('https://www.nicehash.com/api?method=stats.global.current');
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
function yaamp_get_algos()
|
||||
{
|
||||
return array('sha256', /*'scrypt', 'scryptn',*/ 'neoscrypt', 'quark', 'lyra2', 'qubit', 'c11', 'x11', 'x13', 'x15', 'zr5');
|
||||
return array('sha256', /*'scrypt', 'scryptn',*/ 'neoscrypt', 'quark', 'lyra2', 'qubit', 'c11', 'x11', 'x13', 'x15', 'zr5', 'drop');
|
||||
}
|
||||
|
||||
function yaamp_get_algo_norm($algo)
|
||||
|
@ -28,6 +28,7 @@ function yaamp_get_algo_norm($algo)
|
|||
'blake' => 300,
|
||||
'keccak' => 160,
|
||||
'zr5' => 5.5,
|
||||
'drop' => 1.5,
|
||||
);
|
||||
|
||||
if(!isset($a[$algo]))
|
||||
|
@ -43,7 +44,7 @@ function getAlgoColors($algo)
|
|||
'scrypt' => '#c0c0e0',
|
||||
'neoscrypt' => '#a0d0f0',
|
||||
'scryptn' => '#d0d0d0',
|
||||
'c11' => '#f0b0b0',
|
||||
'c11' => '#e0f0b0',
|
||||
'x11' => '#f0f0a0',
|
||||
'x13' => '#d0f0c0',
|
||||
'x14' => '#a0f0c0',
|
||||
|
@ -52,7 +53,8 @@ function getAlgoColors($algo)
|
|||
'quark' => '#c0c0c0',
|
||||
'qubit' => '#d0a0f0',
|
||||
'lyra2' => '#80a0f0',
|
||||
'zr5' => '#d0d0d0',
|
||||
'zr5' => '#d0b0d0',
|
||||
'drop' => '#d0b0d0',
|
||||
);
|
||||
|
||||
if(!isset($a[$algo]))
|
||||
|
@ -84,7 +86,8 @@ function getAlgoPort($algo)
|
|||
'skein' => 4933,
|
||||
'groestl' => 5033,
|
||||
'keccak' => 5133,
|
||||
'zr5' => 5233,
|
||||
'drop' => 5033,
|
||||
'zr5' => 5533,
|
||||
);
|
||||
|
||||
if(!isset($a[$algo]))
|
||||
|
|
|
@ -61,8 +61,9 @@ is the reference with a factor of 1.</p>
|
|||
'x13' => 3.9,
|
||||
'x14' => 3.7,
|
||||
'x15' => 3.5,
|
||||
'nist5' => 15,
|
||||
'zr5' => 15,
|
||||
'nist5' => 6.0,
|
||||
'zr5' => 10.0,
|
||||
'drop' => 5.0;
|
||||
'neoscrypt' => 0.3,
|
||||
'lyra2' => 1.3,
|
||||
'quark' => 6,
|
||||
|
|
Loading…
Add table
Reference in a new issue