mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
handle lbry algo and protocol
Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
This commit is contained in:
parent
38a35f0084
commit
a88c1e0b43
12 changed files with 155 additions and 5 deletions
1
rc.local
1
rc.local
|
@ -38,6 +38,7 @@ screen -dmS quark $STRATUM_DIR/run.sh quark
|
|||
screen -dmS qubit $STRATUM_DIR/run.sh qubit
|
||||
#screen -dmS dmd-gr $STRATUM_DIR/run.sh dmd-gr
|
||||
screen -dmS myr-gr $STRATUM_DIR/run.sh myr-gr
|
||||
screen -dmS lbry $STRATUM_DIR/run.sh lbry
|
||||
screen -dmS lyra2 $STRATUM_DIR/run.sh lyra2
|
||||
screen -dmS lyra2v2 $STRATUM_DIR/run.sh lyra2v2
|
||||
|
||||
|
|
65
stratum/algos/lbry.c
Normal file
65
stratum/algos/lbry.c
Normal file
|
@ -0,0 +1,65 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../sha3/sph_sha2.h"
|
||||
#include "../sha3/sph_ripemd.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
static void hexlify(char *hex, const unsigned char *bin, int len)
|
||||
{
|
||||
hex[0] = 0;
|
||||
for(int i=0; i < len; i++)
|
||||
sprintf(hex+strlen(hex), "%02x", bin[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
void lbry_hash(const char* input, char* output, uint32_t len)
|
||||
{
|
||||
uint32_t hashA[16];
|
||||
uint32_t hashB[8];
|
||||
uint32_t hashC[8];
|
||||
|
||||
sph_sha256_context ctx_sha256;
|
||||
sph_sha512_context ctx_sha512;
|
||||
sph_ripemd160_context ctx_ripemd;
|
||||
|
||||
sph_sha256_init(&ctx_sha256);
|
||||
sph_sha512_init(&ctx_sha512);
|
||||
sph_ripemd160_init(&ctx_ripemd);
|
||||
|
||||
sph_sha256(&ctx_sha256, input, 112);
|
||||
sph_sha256_close(&ctx_sha256, hashA);
|
||||
sph_sha256(&ctx_sha256, hashA, 32);
|
||||
sph_sha256_close(&ctx_sha256, hashA);
|
||||
|
||||
sph_sha512(&ctx_sha512, hashA, 32);
|
||||
sph_sha512_close(&ctx_sha512, hashA);
|
||||
|
||||
sph_ripemd160(&ctx_ripemd, hashA, 32); // sha512 low
|
||||
sph_ripemd160_close(&ctx_ripemd, hashB);
|
||||
|
||||
sph_ripemd160(&ctx_ripemd, &hashA[8], 32); // sha512 high
|
||||
sph_ripemd160_close(&ctx_ripemd, hashC);
|
||||
|
||||
sph_sha256(&ctx_sha256, hashB, 20);
|
||||
sph_sha256(&ctx_sha256, hashC, 20);
|
||||
sph_sha256_close(&ctx_sha256, hashA);
|
||||
|
||||
sph_sha256(&ctx_sha256, hashA, 32);
|
||||
sph_sha256_close(&ctx_sha256, hashA);
|
||||
|
||||
memcpy(output, hashA, 32);
|
||||
|
||||
#ifdef DEBUG
|
||||
char hex[512] = { 0 };
|
||||
hexlify(hex, input, len);
|
||||
fprintf(stderr, "input %s (%d)\n", hex, len);
|
||||
|
||||
hexlify(hex, output, 32);
|
||||
fprintf(stderr, "output %s\n", hex);
|
||||
#endif
|
||||
}
|
16
stratum/algos/lbry.h
Normal file
16
stratum/algos/lbry.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef LBRY_H
|
||||
#define LBRY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void lbry_hash(const char* input, char* output, uint32_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -12,7 +12,7 @@ SOURCES=lyra2re.c lyra2v2.c Lyra2.c Sponge.c blake.c scrypt.c c11.c x11.c x13.c
|
|||
x14.c x15.c x17.c nist5.c fresh.c quark.c neoscrypt.c scryptn.c qubit.c skein.c groestl.c \
|
||||
skein2.c zr5.c bmw.c luffa.c pentablake.c whirlpool.c whirlpoolx.c blakecoin.c \
|
||||
blake2.c blake2s.c \
|
||||
yescrypt.c yescrypt-opt.c sha256_Y.c \
|
||||
yescrypt.c yescrypt-opt.c sha256_Y.c lbry.c \
|
||||
m7m.c magimath.cpp velvet.c \
|
||||
argon2a.c ar2/blake2b.c ar2/argon2.c ar2/ref.c ar2/cores.c ar2/ar2-scrypt-jane.c \
|
||||
hive.c pomelo.c \
|
||||
|
|
|
@ -30,10 +30,16 @@ void build_submit_values(YAAMP_JOB_VALUES *submitvalues, YAAMP_JOB_TEMPLATE *tem
|
|||
#ifdef MERKLE_DEBUGLOG
|
||||
printf("merkle root %s\n", merkleroot.c_str());
|
||||
#endif
|
||||
sprintf(submitvalues->header, "%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be,
|
||||
ntime, templ->nbits, nonce);
|
||||
if (!strcmp(g_current_algo->name, "lbry")) {
|
||||
sprintf(submitvalues->header, "%s%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be,
|
||||
templ->claim_be, ntime, templ->nbits, nonce);
|
||||
ser_string_be(submitvalues->header, submitvalues->header_be, 32 + 20);
|
||||
} else {
|
||||
sprintf(submitvalues->header, "%s%s%s%s%s%s", templ->version, templ->prevhash_be, submitvalues->merkleroot_be,
|
||||
ntime, templ->nbits, nonce);
|
||||
ser_string_be(submitvalues->header, submitvalues->header_be, 20);
|
||||
}
|
||||
|
||||
ser_string_be(submitvalues->header, submitvalues->header_be, 20);
|
||||
binlify(submitvalues->header_bin, submitvalues->header_be);
|
||||
|
||||
// printf("%s\n", submitvalues->header_be);
|
||||
|
@ -482,6 +488,9 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
|
|||
}
|
||||
|
||||
double share_diff = diff_to_target(hash_int);
|
||||
// if (g_current_algo->diff_multiplier != 0) {
|
||||
// share_diff = share_diff / g_current_algo->diff_multiplier;
|
||||
// }
|
||||
|
||||
#ifndef HASH_DEBUGLOG_
|
||||
// only log a few...
|
||||
|
@ -495,4 +504,3 @@ bool client_submit(YAAMP_CLIENT *client, json_value *json_params)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -285,6 +285,31 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
const char *flags = json_get_string(json_coinbaseaux, "flags");
|
||||
strcpy(templ->flags, flags ? flags : "");
|
||||
|
||||
// LBC Claim Tree (with wallet gbt patch)
|
||||
const char *claim = json_get_string(json_result, "claimtrie");
|
||||
if (claim) {
|
||||
strcpy(templ->claim_hex, claim);
|
||||
// debuglog("claimtrie: %s\n", templ->claim_hex);
|
||||
}
|
||||
else if (strcmp(coind->symbol, "LBC") == 0) {
|
||||
json_value *json_claim = rpc_call(&coind->rpc, "getclaimtrie");
|
||||
if (!json_claim || json_claim->type != json_object)
|
||||
return NULL;
|
||||
json_value *json_cls = json_get_array(json_claim, "result");
|
||||
if (!json_cls || !json_is_array(json_cls))
|
||||
return NULL;
|
||||
// get first claim "", seems the root
|
||||
// if empty need 0000000000000000000000000000000000000000000000000000000000000001
|
||||
json_value *json_obj = json_cls->u.array.values[0];
|
||||
if (!json_obj || json_claim->type != json_object)
|
||||
return NULL;
|
||||
claim = json_get_string(json_obj, "hash");
|
||||
if (claim) {
|
||||
strcpy(templ->claim_hex, claim);
|
||||
debuglog("claim_hex: %s\n", templ->claim_hex);
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(coind->rpcencoding, "DCR") == 0) {
|
||||
decred_fix_template(coind, templ, json_result);
|
||||
}
|
||||
|
@ -359,6 +384,9 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
// debuglog("merkle transactions %d [%s]\n", templ->txcount, templ->txmerkles);
|
||||
ser_string_be2(templ->prevhash_hex, templ->prevhash_be, 8);
|
||||
|
||||
if(!strcmp(coind->symbol, "LBC"))
|
||||
ser_string_be2(templ->claim_hex, templ->claim_be, 8);
|
||||
|
||||
if(!coind->pos)
|
||||
coind_aux_build_auxs(templ);
|
||||
|
||||
|
|
16
stratum/config.sample/lbry.conf
Normal file
16
stratum/config.sample/lbry.conf
Normal file
|
@ -0,0 +1,16 @@
|
|||
[TCP]
|
||||
server = yaamp.com
|
||||
port = 3334
|
||||
password = tu8tu5
|
||||
|
||||
[SQL]
|
||||
host = yaampdb
|
||||
database = yaamp
|
||||
username = root
|
||||
password = patofpaq
|
||||
|
||||
[STRATUM]
|
||||
algo = lbry
|
||||
difficulty = 1
|
||||
max_ttf = 40000000
|
||||
|
|
@ -27,6 +27,9 @@ struct YAAMP_JOB_TEMPLATE
|
|||
char prevhash_hex[1024];
|
||||
char prevhash_be[1024];
|
||||
|
||||
char claim_hex[128];
|
||||
char claim_be[128];
|
||||
|
||||
int txcount;
|
||||
char txmerkles[YAAMP_SMALLBUFSIZE];
|
||||
|
||||
|
|
|
@ -16,6 +16,14 @@ static void job_mining_notify_buffer(YAAMP_JOB *job, char *buffer)
|
|||
{
|
||||
YAAMP_JOB_TEMPLATE *templ = job->templ;
|
||||
|
||||
if (!strcmp(g_current_algo->name, "lbry")) {
|
||||
sprintf(buffer, "{\"id\":null,\"method\":\"mining.notify\",\"params\":["
|
||||
"\"%x\",\"%s\",\"%s\",\"%s\",\"%s\",[%s],\"%s\",\"%s\",\"%s\",true]}\n",
|
||||
job->id, templ->prevhash_be, templ->claim_be, templ->coinb1, templ->coinb2,
|
||||
templ->txmerkles, templ->version, templ->nbits, templ->ntime);
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf(buffer, "{\"id\":null,\"method\":\"mining.notify\",\"params\":[\"%x\",\"%s\",\"%s\",\"%s\",[%s],\"%s\",\"%s\",\"%s\",true]}\n",
|
||||
job->id, templ->prevhash_be, templ->coinb1, templ->coinb2, templ->txmerkles, templ->version, templ->nbits, templ->ntime);
|
||||
}
|
||||
|
|
|
@ -118,6 +118,7 @@ YAAMP_ALGO g_algos[] =
|
|||
{"keccak", keccak256_hash, 0x80, 0, sha256_hash_hex },
|
||||
|
||||
{"bmw", bmw_hash, 1, 0, 0},
|
||||
{"lbry", lbry_hash, 0x100, 0, 0},
|
||||
{"luffa", luffa_hash, 1, 0, 0},
|
||||
{"penta", penta_hash, 1, 0, 0},
|
||||
{"skein2", skein2_hash, 1, 0, 0},
|
||||
|
|
|
@ -146,6 +146,7 @@ void sha256_double_hash_hex(const char *input, char *output, unsigned int len);
|
|||
#include "algos/keccak.h"
|
||||
|
||||
#include "algos/bmw.h"
|
||||
#include "algos/lbry.h"
|
||||
#include "algos/luffa.h"
|
||||
#include "algos/pentablake.h"
|
||||
#include "algos/whirlpool.h"
|
||||
|
|
|
@ -13,6 +13,7 @@ function yaamp_get_algos()
|
|||
'blake2s',
|
||||
'decred',
|
||||
'keccak',
|
||||
'lbry',
|
||||
'luffa',
|
||||
'lyra2',
|
||||
'lyra2v2',
|
||||
|
@ -119,6 +120,7 @@ function getAlgoColors($algo)
|
|||
'dmd-gr' => '#a0c0f0',
|
||||
'myr-gr' => '#a0c0f0',
|
||||
'keccak' => '#c0f0c0',
|
||||
'lbry' => '#b0d0e0',
|
||||
'luffa' => '#a0c0c0',
|
||||
'm7m' => '#d0a0a0',
|
||||
'penta' => '#80c0c0',
|
||||
|
@ -150,6 +152,7 @@ function getAlgoPort($algo)
|
|||
{
|
||||
$a = array(
|
||||
'sha256' => 3333,
|
||||
'lbry' => 3334,
|
||||
'scrypt' => 3433,
|
||||
'c11' => 3573,
|
||||
'x11' => 3533,
|
||||
|
|
Loading…
Add table
Reference in a new issue