mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
Squashed commit for segwit support:
commit c59abe5d203fabdabcca81ff5f9c6ff133cfae3b Author: Tanguy Pruvot <tanguy.pruvot@gmail.com> Date: Tue Nov 28 11:13:52 2017 +0100 segwit: show a segwit icon on blocks history + remove some inline styles... commit b4a8639370e6837ebc5a2047e7c334e9f931abfc Author: Tanguy Pruvot <tanguy.pruvot@gmail.com> Date: Tue Nov 28 09:55:40 2017 +0100 segwit: cleanup + masternode case tested ok with BSD (block 400996), and with real BTX segwit txs (block 90958) also ok on VTC and GRS commit 926dbd11757ebff7f7d4930266de9b9061c8ab16 Author: Tanguy Pruvot <tanguy.pruvot@gmail.com> Date: Sat Nov 25 18:41:01 2017 +0100 sql: add segwit fields, and ui config and fill block segwit field if it contains segwit txs, an icon is added in the dashboard "last blocks" for these blocks commit 0b13bf55e9dd1d2229d188f0f8382b27642b20da Author: Tanguy Pruvot <tanguy.pruvot@gmail.com> Date: Sat Nov 25 13:47:20 2017 +0100 segwit: include commitment in coinbase + .conf toggle tested ok on BTX, GRS and VTC with normal txs, but the commitment merkle hash maybe need some more love... so, to prevent useless bigger blocks, only generate segwit commitment if a segwit tx is present in mempool to check with real segwit txs... not seen any yet.. commit b508bc87943d9e426cda994c2f53c16c11e8d4c3 Author: Tanguy Pruvot <tanguy.pruvot@gmail.com> Date: Thu Mar 2 11:18:34 2017 +0100 segwit: prepare the witness data, but disabled need more test, may affect the coinbase merkle and the miners... commit 19bd3a83b9ddddd8b5ed4b7a1bdf8cf8c233e346 Author: Tanguy Pruvot <tanguy.pruvot@gmail.com> Date: Thu Mar 2 10:30:29 2017 +0100 stratum: handle and auto toggle segwit if supported
This commit is contained in:
parent
9d65986c57
commit
cbe55a3a84
17 changed files with 189 additions and 68 deletions
7
sql/2017-11-segwit.sql
Normal file
7
sql/2017-11-segwit.sql
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
-- Recent additions to add after db init (.gz)
|
||||||
|
-- mysql yaamp -p < file.sql
|
||||||
|
|
||||||
|
ALTER TABLE `blocks` ADD `segwit` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `txhash`;
|
||||||
|
|
||||||
|
ALTER TABLE `coins` ADD `usesegwit` tinyint(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `usememorypool`;
|
||||||
|
|
|
@ -205,7 +205,7 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL
|
||||||
debuglog("*** ACCEPTED %s %d (+1)\n", coind_aux->name, coind_aux->height);
|
debuglog("*** ACCEPTED %s %d (+1)\n", coind_aux->name, coind_aux->height);
|
||||||
|
|
||||||
block_add(client->userid, client->workerid, coind_aux->id, coind_aux->height, target_to_diff(coin_target_aux),
|
block_add(client->userid, client->workerid, coind_aux->id, coind_aux->height, target_to_diff(coin_target_aux),
|
||||||
target_to_diff(hash_int), coind_aux->aux.hash, "");
|
target_to_diff(hash_int), coind_aux->aux.hash, "", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -270,7 +270,7 @@ static void client_do_submit(YAAMP_CLIENT *client, YAAMP_JOB *job, YAAMP_JOB_VAL
|
||||||
|
|
||||||
block_add(client->userid, client->workerid, coind->id, templ->height,
|
block_add(client->userid, client->workerid, coind->id, templ->height,
|
||||||
target_to_diff(coin_target), target_to_diff(hash_int),
|
target_to_diff(coin_target), target_to_diff(hash_int),
|
||||||
hash1, submitvalues->hash_be);
|
hash1, submitvalues->hash_be, templ->has_segwit_txs);
|
||||||
|
|
||||||
if(coind->noblocknotify) {
|
if(coind->noblocknotify) {
|
||||||
// DCR go wallet doesnt handle blocknotify= config (yet)
|
// DCR go wallet doesnt handle blocknotify= config (yet)
|
||||||
|
|
|
@ -66,6 +66,7 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
|
||||||
{
|
{
|
||||||
char eheight[32], etime[32];
|
char eheight[32], etime[32];
|
||||||
char entime[32] = { 0 };
|
char entime[32] = { 0 };
|
||||||
|
char commitment[128] = { 0 };
|
||||||
|
|
||||||
ser_number(templ->height, eheight);
|
ser_number(templ->height, eheight);
|
||||||
ser_number(time(NULL), etime);
|
ser_number(time(NULL), etime);
|
||||||
|
@ -90,6 +91,10 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
|
||||||
|
|
||||||
sprintf(templ->coinb2, "%s00000000", script2);
|
sprintf(templ->coinb2, "%s00000000", script2);
|
||||||
|
|
||||||
|
// segwit commitment, if needed
|
||||||
|
if (templ->has_segwit_txs)
|
||||||
|
sprintf(commitment, "0000000000000000%02x%s", (int) (strlen(coind->commitment)/2), coind->commitment);
|
||||||
|
|
||||||
json_int_t available = templ->value;
|
json_int_t available = templ->value;
|
||||||
|
|
||||||
// sample coins using mandatory dev/foundation fees
|
// sample coins using mandatory dev/foundation fees
|
||||||
|
@ -158,7 +163,12 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
|
||||||
available -= charity_amount;
|
available -= charity_amount;
|
||||||
coind->charity_amount = charity_amount;
|
coind->charity_amount = charity_amount;
|
||||||
|
|
||||||
strcat(templ->coinb2, "02");
|
if (templ->has_segwit_txs) {
|
||||||
|
strcat(templ->coinb2, "03"); // 3 outputs (nulldata + fees + miner)
|
||||||
|
strcat(templ->coinb2, commitment);
|
||||||
|
} else {
|
||||||
|
strcat(templ->coinb2, "02");
|
||||||
|
}
|
||||||
job_pack_tx(coind, templ->coinb2, available, NULL);
|
job_pack_tx(coind, templ->coinb2, available, NULL);
|
||||||
job_pack_tx(coind, templ->coinb2, charity_amount, script_payee);
|
job_pack_tx(coind, templ->coinb2, charity_amount, script_payee);
|
||||||
strcat(templ->coinb2, "00000000"); // locktime
|
strcat(templ->coinb2, "00000000"); // locktime
|
||||||
|
@ -350,6 +360,7 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
|
||||||
json_int_t charity_amount = json_get_int(json_result, "payee_amount");
|
json_int_t charity_amount = json_get_int(json_result, "payee_amount");
|
||||||
bool charity_payments = json_get_bool(json_result, "masternode_payments");
|
bool charity_payments = json_get_bool(json_result, "masternode_payments");
|
||||||
bool charity_enforce = json_get_bool(json_result, "enforce_masternode_payments");
|
bool charity_enforce = json_get_bool(json_result, "enforce_masternode_payments");
|
||||||
|
|
||||||
if(strcmp(coind->symbol, "CRW") == 0)
|
if(strcmp(coind->symbol, "CRW") == 0)
|
||||||
{
|
{
|
||||||
char script_dests[2048] = { 0 };
|
char script_dests[2048] = { 0 };
|
||||||
|
@ -390,29 +401,41 @@ void coinbase_create(YAAMP_COIND *coind, YAAMP_JOB_TEMPLATE *templ, json_value *
|
||||||
//debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests);
|
//debuglog("%s %d dests %s\n", coind->symbol, npayees, script_dests);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(charity_payments && charity_enforce)
|
if(charity_payments && charity_enforce)
|
||||||
{
|
{
|
||||||
available -= charity_amount;
|
char script_payee[256] = { 0 };
|
||||||
|
|
||||||
char script_payee[1024];
|
|
||||||
base58_decode(charity_payee, script_payee);
|
base58_decode(charity_payee, script_payee);
|
||||||
|
|
||||||
strcat(templ->coinb2, "02");
|
if (templ->has_segwit_txs) {
|
||||||
|
strcat(templ->coinb2, "03"); // 3 outputs (nulldata + node + miner)
|
||||||
|
strcat(templ->coinb2, commitment);
|
||||||
|
} else {
|
||||||
|
strcat(templ->coinb2, "02"); // 2 outputs
|
||||||
|
}
|
||||||
|
|
||||||
job_pack_tx(coind, templ->coinb2, charity_amount, script_payee);
|
job_pack_tx(coind, templ->coinb2, charity_amount, script_payee);
|
||||||
}
|
available -= charity_amount;
|
||||||
else
|
|
||||||
|
} else {
|
||||||
strcat(templ->coinb2, "01");
|
strcat(templ->coinb2, "01");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else if (templ->has_segwit_txs) {
|
||||||
|
strcat(templ->coinb2, "02");
|
||||||
|
strcat(templ->coinb2, commitment);
|
||||||
|
} else {
|
||||||
strcat(templ->coinb2, "01");
|
strcat(templ->coinb2, "01");
|
||||||
|
}
|
||||||
|
|
||||||
job_pack_tx(coind, templ->coinb2, available, NULL);
|
job_pack_tx(coind, templ->coinb2, available, NULL);
|
||||||
strcat(templ->coinb2, "00000000"); // locktime
|
|
||||||
|
|
||||||
//if(coind->txmessage)
|
//if(coind->txmessage)
|
||||||
// strcat(templ->coinb2, "00");
|
// strcat(templ->coinb2, "00");
|
||||||
|
|
||||||
|
strcat(templ->coinb2, "00000000"); // locktime
|
||||||
|
|
||||||
coind->reward = (double)available/100000000*coind->reward_mul;
|
coind->reward = (double)available/100000000*coind->reward_mul;
|
||||||
// debuglog("coinbase %f\n", coind->reward);
|
// debuglog("coinbase %f\n", coind->reward);
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,10 @@ public:
|
||||||
bool noblocknotify;
|
bool noblocknotify;
|
||||||
bool multialgos; // pow_hash field (or mined_hash)
|
bool multialgos; // pow_hash field (or mined_hash)
|
||||||
|
|
||||||
|
bool usesegwit;
|
||||||
|
char commitment[128];
|
||||||
|
char witness_magic[16];
|
||||||
|
|
||||||
YAAMP_JOB *job;
|
YAAMP_JOB *job;
|
||||||
// YAAMP_JOB_TEMPLATE *templ;
|
// YAAMP_JOB_TEMPLATE *templ;
|
||||||
};
|
};
|
||||||
|
|
|
@ -233,8 +233,9 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
||||||
if(coind->usememorypool)
|
if(coind->usememorypool)
|
||||||
return coind_create_template_memorypool(coind);
|
return coind_create_template_memorypool(coind);
|
||||||
|
|
||||||
char params[4*1024] = "[{}]";
|
char params[512] = "[{}]";
|
||||||
if(!strcmp(coind->symbol, "PPC")) strcpy(params, "[]");
|
if(!strcmp(coind->symbol, "PPC")) strcpy(params, "[]");
|
||||||
|
else if(g_stratum_segwit) strcpy(params, "[{\"rules\":[\"segwit\"]}]");
|
||||||
|
|
||||||
json_value *json = rpc_call(&coind->rpc, "getblocktemplate", params);
|
json_value *json = rpc_call(&coind->rpc, "getblocktemplate", params);
|
||||||
if(!json || json_is_null(json))
|
if(!json || json_is_null(json))
|
||||||
|
@ -255,6 +256,26 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// segwit rule
|
||||||
|
json_value *json_rules = json_get_array(json_result, "rules");
|
||||||
|
if(json_rules && !strlen(coind->witness_magic) && json_rules->u.array.length) {
|
||||||
|
for (int i=0; i<json_rules->u.array.length; i++) {
|
||||||
|
json_value *val = json_rules->u.array.values[i];
|
||||||
|
if(!strcmp(val->u.string.ptr, "segwit")) {
|
||||||
|
const char *commitment = json_get_string(json_result, "default_witness_commitment");
|
||||||
|
strcpy(coind->witness_magic, "aa21a9ed");
|
||||||
|
if (commitment && strlen(commitment) > 12) {
|
||||||
|
strncpy(coind->witness_magic, &commitment[4], 8);
|
||||||
|
coind->witness_magic[8] = '\0';
|
||||||
|
}
|
||||||
|
coind->usesegwit |= g_stratum_segwit;
|
||||||
|
if (coind->usesegwit)
|
||||||
|
debuglog("%s segwit enabled, magic %s\n", coind->symbol, coind->witness_magic);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
json_value *json_tx = json_get_array(json_result, "transactions");
|
json_value *json_tx = json_get_array(json_result, "transactions");
|
||||||
if(!json_tx)
|
if(!json_tx)
|
||||||
{
|
{
|
||||||
|
@ -355,26 +376,78 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
vector<string> txhashes;
|
vector<string> txhashes;
|
||||||
|
vector<string> txids;
|
||||||
txhashes.push_back("");
|
txhashes.push_back("");
|
||||||
|
txids.push_back("");
|
||||||
|
|
||||||
|
templ->has_segwit_txs = false;
|
||||||
|
// to force/test
|
||||||
|
// templ->has_segwit_txs = coind->usesegwit = (coind->usesegwit || g_stratum_segwit);
|
||||||
for(int i = 0; i < json_tx->u.array.length; i++)
|
for(int i = 0; i < json_tx->u.array.length; i++)
|
||||||
{
|
{
|
||||||
const char *p = json_get_string(json_tx->u.array.values[i], "hash");
|
const char *p = json_get_string(json_tx->u.array.values[i], "hash");
|
||||||
|
char hash_be[256] = { 0 };
|
||||||
char hash_be[1024];
|
|
||||||
memset(hash_be, 0, 1024);
|
|
||||||
string_be(p, hash_be);
|
string_be(p, hash_be);
|
||||||
|
|
||||||
txhashes.push_back(hash_be);
|
txhashes.push_back(hash_be);
|
||||||
|
|
||||||
|
const char *txid = json_get_string(json_tx->u.array.values[i], "txid");
|
||||||
|
if(txid && strlen(txid)) {
|
||||||
|
char txid_be[256] = { 0 };
|
||||||
|
string_be(txid, txid_be);
|
||||||
|
txids.push_back(txid_be);
|
||||||
|
if (strcmp(hash_be, txid_be)) {
|
||||||
|
//debuglog("%s segwit tx found, height %d\n", coind->symbol, templ->height);
|
||||||
|
templ->has_segwit_txs = true; // if not, its useless to generate a segwit block, bigger
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
templ->has_segwit_txs = false; // force disable if not supported (no txid fields)
|
||||||
|
}
|
||||||
|
|
||||||
const char *d = json_get_string(json_tx->u.array.values[i], "data");
|
const char *d = json_get_string(json_tx->u.array.values[i], "data");
|
||||||
templ->txdata.push_back(d);
|
templ->txdata.push_back(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
templ->txmerkles[0] = 0;
|
templ->txmerkles[0] = '\0';
|
||||||
templ->txcount = txhashes.size();
|
if(templ->has_segwit_txs) {
|
||||||
templ->txsteps = merkle_steps(txhashes);
|
templ->txcount = txids.size();
|
||||||
|
templ->txsteps = merkle_steps(txids);
|
||||||
|
} else {
|
||||||
|
templ->txcount = txhashes.size();
|
||||||
|
templ->txsteps = merkle_steps(txhashes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(templ->has_segwit_txs) {
|
||||||
|
// * We compute the witness hash (which is the hash including witnesses) of all the block's transactions, except the
|
||||||
|
// coinbase (where 0x0000....0000 is used instead).
|
||||||
|
// * The coinbase scriptWitness is a stack of a single 32-byte vector, containing a witness nonce (unconstrained).
|
||||||
|
// * We build a merkle tree with all those witness hashes as leaves (similar to the hashMerkleRoot in the block header).
|
||||||
|
// * There must be at least one output whose scriptPubKey is a single 36-byte push, the first 4 bytes (magic) of which are
|
||||||
|
// {0xaa, 0x21, 0xa9, 0xed}, and the following 32 bytes are SHA256^2(witness root, witness nonce). In case there are
|
||||||
|
/*
|
||||||
|
char bin[YAAMP_HASHLEN_BIN*2];
|
||||||
|
char witness[128] = { 0 };
|
||||||
|
vector<string> mt_verify = merkle_steps(txhashes);
|
||||||
|
string witness_mt = merkle_with_first(mt_verify, "0000000000000000000000000000000000000000000000000000000000000000");
|
||||||
|
mt_verify.clear();
|
||||||
|
witness_mt = witness_mt + "0000000000000000000000000000000000000000000000000000000000000000";
|
||||||
|
|
||||||
|
binlify((unsigned char *)bin, witness_mt.c_str());
|
||||||
|
sha256_double_hash_hex(bin, witness, YAAMP_HASHLEN_BIN*2);
|
||||||
|
|
||||||
|
int clen = (int) (strlen(coind->witness_magic) + strlen(witness)); // 4 + 32 = 36 = 0x24
|
||||||
|
sprintf(coind->commitment, "6a%02x%s%s", clen/2, coind->witness_magic, witness);
|
||||||
|
*/
|
||||||
|
// default commitment is already computed correctly
|
||||||
|
const char *commitment = json_get_string(json_result, "default_witness_commitment");
|
||||||
|
if (commitment) {
|
||||||
|
sprintf(coind->commitment, "%s", commitment);
|
||||||
|
} else {
|
||||||
|
templ->has_segwit_txs = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
txhashes.clear();
|
txhashes.clear();
|
||||||
|
txids.clear();
|
||||||
|
|
||||||
vector<string>::const_iterator i;
|
vector<string>::const_iterator i;
|
||||||
for(i = templ->txsteps.begin(); i != templ->txsteps.end(); ++i)
|
for(i = templ->txsteps.begin(); i != templ->txsteps.end(); ++i)
|
||||||
|
|
|
@ -158,7 +158,7 @@ void db_update_coinds(YAAMP_DB *db)
|
||||||
db_query(db, "SELECT id, name, rpchost, rpcport, rpcuser, rpcpasswd, rpcencoding, master_wallet, reward, price, "
|
db_query(db, "SELECT id, name, rpchost, rpcport, rpcuser, rpcpasswd, rpcencoding, master_wallet, reward, price, "
|
||||||
"hassubmitblock, txmessage, enable, auto_ready, algo, pool_ttf, charity_address, charity_amount, charity_percent, "
|
"hassubmitblock, txmessage, enable, auto_ready, algo, pool_ttf, charity_address, charity_amount, charity_percent, "
|
||||||
"reward_mul, symbol, auxpow, actual_ttf, network_ttf, usememorypool, hasmasternodes, algo, symbol2, "
|
"reward_mul, symbol, auxpow, actual_ttf, network_ttf, usememorypool, hasmasternodes, algo, symbol2, "
|
||||||
"rpccurl, rpcssl, rpccert, account, multialgos, max_miners, max_shares "
|
"rpccurl, rpcssl, rpccert, account, multialgos, max_miners, max_shares, usesegwit "
|
||||||
"FROM coins WHERE enable AND auto_ready AND algo='%s' ORDER BY index_avg", g_stratum_algo);
|
"FROM coins WHERE enable AND auto_ready AND algo='%s' ORDER BY index_avg", g_stratum_algo);
|
||||||
|
|
||||||
MYSQL_RES *result = mysql_store_result(&db->mysql);
|
MYSQL_RES *result = mysql_store_result(&db->mysql);
|
||||||
|
@ -258,6 +258,9 @@ void db_update_coinds(YAAMP_DB *db)
|
||||||
if(row[32]) coind->multialgos = atoi(row[32]);
|
if(row[32]) coind->multialgos = atoi(row[32]);
|
||||||
if(row[33] && atoi(row[33]) > 0) g_stratum_max_cons = atoi(row[33]);
|
if(row[33] && atoi(row[33]) > 0) g_stratum_max_cons = atoi(row[33]);
|
||||||
if(row[34] && atol(row[34]) > 0) g_max_shares = atol(row[34]);
|
if(row[34] && atol(row[34]) > 0) g_max_shares = atol(row[34]);
|
||||||
|
if(row[35]) coind->usesegwit = atoi(row[35]) > 0;
|
||||||
|
|
||||||
|
if(coind->usesegwit) g_stratum_segwit = true;
|
||||||
|
|
||||||
// force the right rpcencoding for DCR
|
// force the right rpcencoding for DCR
|
||||||
if(!strcmp(coind->symbol, "DCR") && strcmp(coind->rpcencoding, "DCR"))
|
if(!strcmp(coind->symbol, "DCR") && strcmp(coind->rpcencoding, "DCR"))
|
||||||
|
|
|
@ -50,6 +50,8 @@ struct YAAMP_JOB_TEMPLATE
|
||||||
|
|
||||||
char header[256];
|
char header[256];
|
||||||
|
|
||||||
|
bool has_segwit_txs;
|
||||||
|
|
||||||
int auxs_size;
|
int auxs_size;
|
||||||
YAAMP_COIND_AUX *auxs[MAX_AUXS];
|
YAAMP_COIND_AUX *auxs[MAX_AUXS];
|
||||||
};
|
};
|
||||||
|
|
|
@ -180,7 +180,7 @@ void share_prune(YAAMP_DB *db)
|
||||||
void block_prune(YAAMP_DB *db)
|
void block_prune(YAAMP_DB *db)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char buffer[128*1024] = "insert into blocks (height, blockhash, coin_id, userid, workerid, category, difficulty, difficulty_user, time, algo) values ";
|
char buffer[128*1024] = "insert into blocks (height, blockhash, coin_id, userid, workerid, category, difficulty, difficulty_user, time, algo, segwit) values ";
|
||||||
|
|
||||||
g_list_block.Enter();
|
g_list_block.Enter();
|
||||||
for(CLI li = g_list_block.first; li; li = li->next)
|
for(CLI li = g_list_block.first; li; li = li->next)
|
||||||
|
@ -199,9 +199,9 @@ void block_prune(YAAMP_DB *db)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count) strcat(buffer, ",");
|
if(count) strcat(buffer, ",");
|
||||||
sprintf(buffer+strlen(buffer), "(%d, '%s', %d, %d, %d, 'new', %f, %f, %d, '%s')",
|
sprintf(buffer+strlen(buffer), "(%d, '%s', %d, %d, %d, 'new', %f, %f, %d, '%s', %d)",
|
||||||
block->height, block->hash, block->coinid, block->userid, block->workerid,
|
block->height, block->hash, block->coinid, block->userid, block->workerid,
|
||||||
block->difficulty, block->difficulty_user, (int)block->created, g_stratum_algo);
|
block->difficulty, block->difficulty_user, (int)block->created, g_stratum_algo, block->segwit?1:0);
|
||||||
|
|
||||||
object_delete(block);
|
object_delete(block);
|
||||||
count++;
|
count++;
|
||||||
|
@ -211,7 +211,7 @@ void block_prune(YAAMP_DB *db)
|
||||||
if(count) db_query(db, buffer);
|
if(count) db_query(db, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void block_add(int userid, int workerid, int coinid, int height, double difficulty, double difficulty_user, const char *hash1, const char *hash2)
|
void block_add(int userid, int workerid, int coinid, int height, double diff, double diff_user, const char *h1, const char *h2, int segwit)
|
||||||
{
|
{
|
||||||
YAAMP_BLOCK *block = new YAAMP_BLOCK;
|
YAAMP_BLOCK *block = new YAAMP_BLOCK;
|
||||||
memset(block, 0, sizeof(YAAMP_BLOCK));
|
memset(block, 0, sizeof(YAAMP_BLOCK));
|
||||||
|
@ -221,11 +221,12 @@ void block_add(int userid, int workerid, int coinid, int height, double difficul
|
||||||
block->workerid = workerid;
|
block->workerid = workerid;
|
||||||
block->coinid = coinid;
|
block->coinid = coinid;
|
||||||
block->height = height;
|
block->height = height;
|
||||||
block->difficulty = difficulty;
|
block->difficulty = diff;
|
||||||
block->difficulty_user = difficulty_user;
|
block->difficulty_user = diff_user;
|
||||||
|
block->segwit = segwit;
|
||||||
|
|
||||||
strcpy(block->hash1, hash1);
|
strcpy(block->hash1, h1);
|
||||||
strcpy(block->hash2, hash2);
|
strcpy(block->hash2, h2);
|
||||||
|
|
||||||
g_list_block.AddTail(block);
|
g_list_block.AddTail(block);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public:
|
||||||
|
|
||||||
bool valid;
|
bool valid;
|
||||||
bool extranonce1;
|
bool extranonce1;
|
||||||
int error_number;
|
int32_t error_number;
|
||||||
|
|
||||||
uint32_t ntime;
|
uint32_t ntime;
|
||||||
double difficulty;
|
double difficulty;
|
||||||
|
@ -56,8 +56,9 @@ void share_prune(YAAMP_DB *db);
|
||||||
class YAAMP_BLOCK: public YAAMP_OBJECT
|
class YAAMP_BLOCK: public YAAMP_OBJECT
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int created;
|
time_t created;
|
||||||
bool confirmed;
|
bool confirmed;
|
||||||
|
bool segwit;
|
||||||
|
|
||||||
int userid;
|
int userid;
|
||||||
int workerid;
|
int workerid;
|
||||||
|
@ -83,7 +84,7 @@ inline void block_delete(YAAMP_OBJECT *object)
|
||||||
class YAAMP_SUBMIT: public YAAMP_OBJECT
|
class YAAMP_SUBMIT: public YAAMP_OBJECT
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
int created;
|
time_t created;
|
||||||
bool valid;
|
bool valid;
|
||||||
|
|
||||||
int remoteid;
|
int remoteid;
|
||||||
|
@ -98,7 +99,7 @@ inline void submit_delete(YAAMP_OBJECT *object)
|
||||||
|
|
||||||
void block_prune(YAAMP_DB *db);
|
void block_prune(YAAMP_DB *db);
|
||||||
|
|
||||||
void block_add(int userid, int workerid, int coinid, int height, double difficulty, double difficulty_user, const char *hash1, const char *hash2);
|
void block_add(int userid, int workerid, int coinid, int height, double diff, double diff_user, const char *hash1, const char *h2, int segwit);
|
||||||
void block_confirm(int coinid, const char *hash);
|
void block_confirm(int coinid, const char *hash);
|
||||||
|
|
||||||
YAAMP_SUBMIT *submit_add(int remoteid, double difficulty);
|
YAAMP_SUBMIT *submit_add(int remoteid, double difficulty);
|
||||||
|
|
|
@ -31,6 +31,7 @@ int g_stratum_max_ttf;
|
||||||
int g_stratum_max_cons = 5000;
|
int g_stratum_max_cons = 5000;
|
||||||
bool g_stratum_reconnect;
|
bool g_stratum_reconnect;
|
||||||
bool g_stratum_renting;
|
bool g_stratum_renting;
|
||||||
|
bool g_stratum_segwit;
|
||||||
bool g_autoexchange = true;
|
bool g_autoexchange = true;
|
||||||
|
|
||||||
uint64_t g_max_shares = 0;
|
uint64_t g_max_shares = 0;
|
||||||
|
@ -221,6 +222,7 @@ int main(int argc, char **argv)
|
||||||
g_stratum_max_ttf = iniparser_getint(ini, "STRATUM:max_ttf", 0x70000000);
|
g_stratum_max_ttf = iniparser_getint(ini, "STRATUM:max_ttf", 0x70000000);
|
||||||
g_stratum_reconnect = iniparser_getint(ini, "STRATUM:reconnect", true);
|
g_stratum_reconnect = iniparser_getint(ini, "STRATUM:reconnect", true);
|
||||||
g_stratum_renting = iniparser_getint(ini, "STRATUM:renting", true);
|
g_stratum_renting = iniparser_getint(ini, "STRATUM:renting", true);
|
||||||
|
g_stratum_segwit = iniparser_getint(ini, "STRATUM:segwit", 0);
|
||||||
|
|
||||||
iniparser_freedict(ini);
|
iniparser_freedict(ini);
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ extern int g_stratum_max_cons;
|
||||||
extern int g_stratum_max_ttf;
|
extern int g_stratum_max_ttf;
|
||||||
extern bool g_stratum_reconnect;
|
extern bool g_stratum_reconnect;
|
||||||
extern bool g_stratum_renting;
|
extern bool g_stratum_renting;
|
||||||
|
extern bool g_stratum_segwit;
|
||||||
|
|
||||||
extern uint64_t g_max_shares;
|
extern uint64_t g_max_shares;
|
||||||
extern uint64_t g_shares_counter;
|
extern uint64_t g_shares_counter;
|
||||||
|
|
BIN
web/images/ui/segwit.png
Normal file
BIN
web/images/ui/segwit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 448 B |
|
@ -49,6 +49,7 @@ class db_coins extends CActiveRecord
|
||||||
'serveruser' => 'Server user',
|
'serveruser' => 'Server user',
|
||||||
'hassubmitblock'=> 'Has submitblock',
|
'hassubmitblock'=> 'Has submitblock',
|
||||||
'hasmasternodes'=> 'Masternodes',
|
'hasmasternodes'=> 'Masternodes',
|
||||||
|
'usesegwit' => 'Use segwit',
|
||||||
'market' => 'Preferred market',
|
'market' => 'Preferred market',
|
||||||
'rpcencoding' => 'RPC Type',
|
'rpcencoding' => 'RPC Type',
|
||||||
'specifications'=> 'Notes'
|
'specifications'=> 'Notes'
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
|
JavascriptFile("/yaamp/ui/js/jquery.metadata.js");
|
||||||
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");
|
JavascriptFile("/yaamp/ui/js/jquery.tablesorter.widgets.js");
|
||||||
|
|
||||||
$id = getiparam('id');
|
$id = (int) getiparam('id');
|
||||||
if($id)
|
$db_blocks = getdbolist('db_blocks', "coin_id=:id order by time desc limit 250", array(':id'=>$id));
|
||||||
$db_blocks = getdbolist('db_blocks', "coin_id=:id order by time desc limit 250", array(':id'=>$id));
|
$coin = getdbo('db_coins', $id);
|
||||||
else
|
|
||||||
$db_blocks = getdbolist('db_blocks', "1 order by time desc limit 250");
|
|
||||||
|
|
||||||
showTableSorter('maintable', "{
|
showTableSorter('maintable', "{
|
||||||
tableClass: 'dataGrid',
|
tableClass: 'dataGrid',
|
||||||
|
@ -54,7 +52,6 @@ foreach($db_blocks as $db_block)
|
||||||
{
|
{
|
||||||
if(!$db_block->coin_id) continue;
|
if(!$db_block->coin_id) continue;
|
||||||
|
|
||||||
$coin = getdbo('db_coins', $db_block->coin_id);
|
|
||||||
if(!$coin) continue;
|
if(!$coin) continue;
|
||||||
|
|
||||||
if($db_block->category == 'stake' && !$this->admin) continue;
|
if($db_block->category == 'stake' && !$this->admin) continue;
|
||||||
|
@ -74,12 +71,14 @@ foreach($db_blocks as $db_block)
|
||||||
|
|
||||||
echo '<td><img width="16" src="'.$coin->image.'"></td>';
|
echo '<td><img width="16" src="'.$coin->image.'"></td>';
|
||||||
|
|
||||||
|
$flags = $db_block->segwit ? ' <img src="/images/ui/segwit.png" height="8px" valign="center" title="segwit"/>' : '';
|
||||||
|
|
||||||
echo '<td>';
|
echo '<td>';
|
||||||
if ($this->admin)
|
if ($this->admin)
|
||||||
echo '<a href="/site/coin?id='.$coin->id.'"><b>'.$coin->name.'</b></a>';
|
echo '<a href="/site/coin?id='.$coin->id.'"><b>'.$coin->name.'</b></a>';
|
||||||
else
|
else
|
||||||
echo '<b>'.$coin->name.'</b>';
|
echo '<b>'.$coin->name.'</b>';
|
||||||
echo ' ('.$coin->symbol.')</td>';
|
echo ' ('.$coin->symbol.')'.$flags.'</td>';
|
||||||
|
|
||||||
// $db_block->confirmations = $blockext['confirmations'];
|
// $db_block->confirmations = $blockext['confirmations'];
|
||||||
// $db_block->save();
|
// $db_block->save();
|
||||||
|
@ -133,11 +132,3 @@ foreach($db_blocks as $db_block)
|
||||||
|
|
||||||
echo "</tbody></table>";
|
echo "</tbody></table>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,12 @@ echo CUFHtml::activeCheckBox($coin, 'hasmasternodes');
|
||||||
echo '<p class="formHint2">Require "payee" and "payee_amount" fields in getblocktemplate (DASH)</p>';
|
echo '<p class="formHint2">Require "payee" and "payee_amount" fields in getblocktemplate (DASH)</p>';
|
||||||
echo CUFHtml::closeCtrlHolder();
|
echo CUFHtml::closeCtrlHolder();
|
||||||
|
|
||||||
|
echo CUFHtml::openActiveCtrlHolder($coin, 'usesegwit');
|
||||||
|
echo CUFHtml::activeLabelEx($coin, 'usesegwit');
|
||||||
|
echo CUFHtml::activeCheckBox($coin, 'usesegwit');
|
||||||
|
echo '<p class="formHint2"></p>';
|
||||||
|
echo CUFHtml::closeCtrlHolder();
|
||||||
|
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -615,7 +615,8 @@ foreach($db_blocks as $db_block)
|
||||||
$algo_color = getAlgoColors($coin->algo);
|
$algo_color = getAlgoColors($coin->algo);
|
||||||
echo '<tr style="background-color: '.$algo_color.';">';
|
echo '<tr style="background-color: '.$algo_color.';">';
|
||||||
echo '<td width="18px"><img width="16px" src="'.$coin->image.'"></td>';
|
echo '<td width="18px"><img width="16px" src="'.$coin->image.'"></td>';
|
||||||
echo '<td><b><a href="/site/coin?id='.$coin->id.'">'.$coin->name.'</a></b></td>';
|
$flags = $db_block->segwit ? ' <img src="/images/ui/segwit.png" height="8px" valign="center" title="segwit">' : '';
|
||||||
|
echo '<td><b><a href="/site/coin?id='.$coin->id.'">'.$coin->name.'</a></b>'.$flags.'</td>';
|
||||||
|
|
||||||
echo '<td align="right" style="font-size: .8em">'.$db_block->amount.' '.$coin->symbol.'</td>';
|
echo '<td align="right" style="font-size: .8em">'.$db_block->amount.' '.$coin->symbol.'</td>';
|
||||||
echo '<td align="right" style="font-size: .8em" title="found '.$db_block->difficulty_user.'">'.$diff.'</td>';
|
echo '<td align="right" style="font-size: .8em" title="found '.$db_block->difficulty_user.'">'.$diff.'</td>';
|
||||||
|
|
|
@ -35,6 +35,9 @@ span.block.new { color: white; background-color: #ad4ef0; }
|
||||||
span.block.orphan { color: white; background-color: #d9534f; }
|
span.block.orphan { color: white; background-color: #d9534f; }
|
||||||
span.block.immature { color: white; background-color: #f0ad4e; }
|
span.block.immature { color: white; background-color: #f0ad4e; }
|
||||||
span.block.confirmed { color: white; background-color: #5cb85c; }
|
span.block.confirmed { color: white; background-color: #5cb85c; }
|
||||||
|
b.row a { font-size: 10pt; }
|
||||||
|
.ssrow td.row { font-size: .8em; }
|
||||||
|
td.right { text-align: right; }
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<table class="dataGrid2">
|
<table class="dataGrid2">
|
||||||
|
@ -61,17 +64,17 @@ foreach($db_blocks as $db_block)
|
||||||
|
|
||||||
$reward = bitcoinvaluetoa($db_block->amount);
|
$reward = bitcoinvaluetoa($db_block->amount);
|
||||||
|
|
||||||
echo "<tr class='ssrow'>";
|
echo '<tr class="ssrow">';
|
||||||
echo "<td width=18><img width=16 src='/images/btc.png'></td>";
|
echo '<td width="18px"><img width="16px" src="/images/btc.png"/></td>';
|
||||||
echo "<td><b>Rental</b><span style='font-size: .8em'> ($db_block->algo)</span></td>";
|
echo '<td class="row"><b>Rental</b> ('.$db_block->algo.')</td>';
|
||||||
echo "<td align=right style='font-size: .8em'><b>$reward BTC</b></td>";
|
echo '<td class="row right"><b>'.$reward.' BTC</b></td>';
|
||||||
echo "<td align=right style='font-size: .8em'></td>";
|
echo '<td class="row right"></td>';
|
||||||
echo "<td align=right style='font-size: .8em'></td>";
|
echo '<td class="row right"></td>';
|
||||||
echo "<td align=right style='font-size: .8em'>$d ago</td>";
|
echo '<td class="row right">'.$d.' ago</td>';
|
||||||
echo "<td align=right style='font-size: .8em'>";
|
echo '<td class="row right">';
|
||||||
echo "<span style='padding: 2px; color: white; background-color: #5cb85c'>Confirmed</span>";
|
echo '<span class="block confirmed">Confirmed</span>';
|
||||||
echo "</td>";
|
echo '</td>';
|
||||||
echo "</tr>";
|
echo '</tr>';
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -83,14 +86,16 @@ foreach($db_blocks as $db_block)
|
||||||
|
|
||||||
$link = $coin->createExplorerLink($coin->name, array('hash'=>$db_block->blockhash));
|
$link = $coin->createExplorerLink($coin->name, array('hash'=>$db_block->blockhash));
|
||||||
|
|
||||||
|
$flags = $db_block->segwit ? ' <img src="/images/ui/segwit.png" height="8px" valign="center" title="segwit"/>' : '';
|
||||||
|
|
||||||
echo '<tr class="ssrow">';
|
echo '<tr class="ssrow">';
|
||||||
echo '<td width="18"><img width="16" src="'.$coin->image.'"></td>';
|
echo '<td width="18px"><img width="16px" src="'.$coin->image.'"></td>';
|
||||||
echo "<td><b>$link</b><span style='font-size: .8em'> ($coin->algo)</span></td>";
|
echo '<td class="row"><b class="row">'.$link.'</b> ('.$coin->algo.')'.$flags.'</td>';
|
||||||
echo "<td align=right style='font-size: .8em'><b>$reward $coin->symbol_show</b></td>";
|
echo '<td class="row right"><b>'.$reward.' '.$coin->symbol_show.'</b></td>';
|
||||||
echo "<td align=right style='font-size: .8em' title='found $db_block->difficulty_user'>$difficulty</td>";
|
echo '<td class="row right" title="found '.$db_block->difficulty_user.'">'.$difficulty.'</td>';
|
||||||
echo "<td align=right style='font-size: .8em'>$height</td>";
|
echo '<td class="row right">'.$height.'</td>';
|
||||||
echo "<td align=right style='font-size: .8em'>$d ago</td>";
|
echo '<td class="row right">'.$d.' ago</td>';
|
||||||
echo "<td align=right style='font-size: .8em'>";
|
echo '<td class="row right">';
|
||||||
|
|
||||||
if($db_block->category == 'orphan')
|
if($db_block->category == 'orphan')
|
||||||
echo '<span class="block orphan">Orphan</span>';
|
echo '<span class="block orphan">Orphan</span>';
|
||||||
|
|
Loading…
Add table
Reference in a new issue