mirror of
https://github.com/LBRYFoundation/pool.git
synced 2025-08-23 17:37:25 +00:00
stratum: allow to limit txs per block
This commit is contained in:
parent
033d50c9ba
commit
236650dc57
4 changed files with 30 additions and 3 deletions
|
@ -381,12 +381,20 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
txids.push_back("");
|
||||
|
||||
templ->has_segwit_txs = false;
|
||||
// to force/test
|
||||
// templ->has_segwit_txs = coind->usesegwit = (coind->usesegwit || g_stratum_segwit);
|
||||
|
||||
templ->has_filtered_txs = false;
|
||||
templ->filtered_txs_fee = 0;
|
||||
|
||||
for(int i = 0; i < json_tx->u.array.length; i++)
|
||||
{
|
||||
const char *p = json_get_string(json_tx->u.array.values[i], "hash");
|
||||
char hash_be[256] = { 0 };
|
||||
|
||||
if (templ->has_filtered_txs) {
|
||||
templ->filtered_txs_fee += json_get_int(json_tx->u.array.values[i], "fee");
|
||||
continue;
|
||||
}
|
||||
|
||||
string_be(p, hash_be);
|
||||
txhashes.push_back(hash_be);
|
||||
|
||||
|
@ -396,7 +404,6 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
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 {
|
||||
|
@ -405,6 +412,17 @@ YAAMP_JOB_TEMPLATE *coind_create_template(YAAMP_COIND *coind)
|
|||
|
||||
const char *d = json_get_string(json_tx->u.array.values[i], "data");
|
||||
templ->txdata.push_back(d);
|
||||
|
||||
// if wanted, we can limit the count of txs to include
|
||||
if (g_limit_txs_per_block && i >= g_limit_txs_per_block-2) {
|
||||
debuglog("limiting block to %d first txs (of %d)\n", g_limit_txs_per_block, json_tx->u.array.length);
|
||||
templ->has_filtered_txs = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (templ->has_filtered_txs) {
|
||||
// coinbasevalue is a total with all tx fees, need to reduce it if some are skipped
|
||||
templ->value -= templ->filtered_txs_fee;
|
||||
}
|
||||
|
||||
templ->txmerkles[0] = '\0';
|
||||
|
|
|
@ -52,6 +52,9 @@ struct YAAMP_JOB_TEMPLATE
|
|||
|
||||
bool has_segwit_txs;
|
||||
|
||||
bool has_filtered_txs;
|
||||
int filtered_txs_fee;
|
||||
|
||||
int auxs_size;
|
||||
YAAMP_COIND_AUX *auxs[MAX_AUXS];
|
||||
};
|
||||
|
|
|
@ -36,6 +36,9 @@ int g_stratum_max_cons = 5000;
|
|||
bool g_stratum_reconnect;
|
||||
bool g_stratum_renting;
|
||||
bool g_stratum_segwit = false;
|
||||
|
||||
int g_limit_txs_per_block = 0;
|
||||
|
||||
bool g_autoexchange = true;
|
||||
|
||||
uint64_t g_max_shares = 0;
|
||||
|
@ -236,6 +239,8 @@ int main(int argc, char **argv)
|
|||
g_stratum_reconnect = iniparser_getint(ini, "STRATUM:reconnect", true);
|
||||
g_stratum_renting = iniparser_getint(ini, "STRATUM:renting", true);
|
||||
|
||||
g_limit_txs_per_block = iniparser_getint(ini, "STRATUM:max_txs_per_block", 0);
|
||||
|
||||
iniparser_freedict(ini);
|
||||
|
||||
g_current_algo = stratum_find_algo(g_stratum_algo);
|
||||
|
|
|
@ -87,6 +87,7 @@ extern int g_stratum_max_ttf;
|
|||
extern bool g_stratum_reconnect;
|
||||
extern bool g_stratum_renting;
|
||||
extern bool g_stratum_segwit;
|
||||
extern int g_limit_txs_per_block;
|
||||
|
||||
extern uint64_t g_max_shares;
|
||||
extern uint64_t g_shares_counter;
|
||||
|
|
Loading…
Add table
Reference in a new issue