De-duplicate tx hashes and pub keys to save memory (off by default) (#382)

P2Pool-main: 8.2 MB saved
P2Pool-mini: 66 MB saved
P2Pool-nano: 25.2 MB saved

The feature is available only when building from source and is intended for use on low-memory systems (for example, a VPS server with < 1 GB RAM).

It only makes sense to use with `--no-cache --no-randomx` in the command line because cache and RandomX hasher take much more memory.
This commit is contained in:
SChernykh
2025-10-18 12:21:16 +02:00
committed by GitHub
parent 52bcbda381
commit e2f0ec7c69
25 changed files with 640 additions and 103 deletions
+13 -2
View File
@@ -331,12 +331,23 @@ void MergeMiningClientTari::on_external_block(const PoolBlock& block)
std::vector<hash> proof;
uint32_t path;
if (!merkle_hash_with_proof(block.m_transactions, 0, proof, path, root)) {
#ifdef WITH_INDEXED_HASHES
std::vector<hash> transactions;
transactions.reserve(block.m_transactions.size());
for (const auto& h : block.m_transactions) {
transactions.emplace_back(h);
}
#else
const std::vector<hash>& transactions = block.m_transactions;
#endif
if (!merkle_hash_with_proof(transactions, 0, proof, path, root)) {
LOGWARN(3, "on_external_block: merkle_hash_with_proof failed for coinbase transaction");
return;
}
if (!verify_merkle_proof(block.m_transactions[0], proof, path, root)) {
if (!verify_merkle_proof(transactions[0], proof, path, root)) {
LOGWARN(3, "on_external_block: verify_merkle_proof failed for coinbase transaction");
return;
}