mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
Tari: Added coinbase_merkle_proof
to pow_data
This commit is contained in:
parent
d6364709ca
commit
e986e5dc2e
7 changed files with 21 additions and 7 deletions
|
@ -61,6 +61,8 @@ public:
|
||||||
FORCEINLINE const std::vector<MinerShare>& shares() const { return m_shares; }
|
FORCEINLINE const std::vector<MinerShare>& shares() const { return m_shares; }
|
||||||
FORCEINLINE uint64_t get_reward() const { return m_finalReward; }
|
FORCEINLINE uint64_t get_reward() const { return m_finalReward; }
|
||||||
|
|
||||||
|
FORCEINLINE std::vector<uint8_t> get_coinbase_merkle_proof() const { ReadLock lock(m_lock); return m_merkleTreeMainBranch; }
|
||||||
|
|
||||||
#ifdef P2POOL_UNIT_TESTS
|
#ifdef P2POOL_UNIT_TESTS
|
||||||
FORCEINLINE const PoolBlock* pool_block_template() const { return m_poolBlockTemplate; }
|
FORCEINLINE const PoolBlock* pool_block_template() const { return m_poolBlockTemplate; }
|
||||||
FORCEINLINE std::mt19937_64& rng() { return m_rng; }
|
FORCEINLINE std::mt19937_64& rng() { return m_rng; }
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
virtual ~IMergeMiningClient() {}
|
virtual ~IMergeMiningClient() {}
|
||||||
|
|
||||||
[[nodiscard]] virtual bool get_params(ChainParameters& out_params) const = 0;
|
[[nodiscard]] virtual bool get_params(ChainParameters& out_params) const = 0;
|
||||||
virtual void submit_solution(const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof) = 0;
|
virtual void submit_solution(const BlockTemplate* block_tpl, const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace p2pool
|
} // namespace p2pool
|
||||||
|
|
|
@ -283,7 +283,7 @@ bool MergeMiningClientJSON_RPC::parse_merge_mining_get_job(const char* data, siz
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeMiningClientJSON_RPC::submit_solution(const uint8_t (&/*hashing_blob*/)[128], size_t /*nonce_offset*/, const hash& /*seed_hash*/, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof)
|
void MergeMiningClientJSON_RPC::submit_solution(const BlockTemplate* /*block_tpl*/, const uint8_t (&/*hashing_blob*/)[128], size_t /*nonce_offset*/, const hash& /*seed_hash*/, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof)
|
||||||
{
|
{
|
||||||
ReadLock lock(m_lock);
|
ReadLock lock(m_lock);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
~MergeMiningClientJSON_RPC() override;
|
~MergeMiningClientJSON_RPC() override;
|
||||||
|
|
||||||
bool get_params(ChainParameters& out_params) const override;
|
bool get_params(ChainParameters& out_params) const override;
|
||||||
void submit_solution(const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof) override;
|
void submit_solution(const BlockTemplate* block_tpl, const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void loop(void* data);
|
static void loop(void* data);
|
||||||
|
|
|
@ -125,7 +125,7 @@ bool MergeMiningClientTari::get_params(ChainParameters& out_params) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MergeMiningClientTari::submit_solution(const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& /*merkle_proof*/)
|
void MergeMiningClientTari::submit_solution(const BlockTemplate* block_tpl, const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& /*merkle_proof*/)
|
||||||
{
|
{
|
||||||
Block block;
|
Block block;
|
||||||
{
|
{
|
||||||
|
@ -157,7 +157,19 @@ void MergeMiningClientTari::submit_solution(const uint8_t (&hashing_blob)[128],
|
||||||
// Tx Merkle tree root
|
// Tx Merkle tree root
|
||||||
data.append(reinterpret_cast<const char*>(hashing_blob + nonce_offset + sizeof(uint32_t)), HASH_SIZE);
|
data.append(reinterpret_cast<const char*>(hashing_blob + nonce_offset + sizeof(uint32_t)), HASH_SIZE);
|
||||||
|
|
||||||
// TODO: serialize coinbase_merkle_proof, coinbase_tx_extra, coinbase_tx_hasher, aux_chain_merkle_proof
|
// Coinbase transaction's Merkle proof
|
||||||
|
const std::vector<uint8_t> coinbase_merkle_proof = block_tpl->get_coinbase_merkle_proof();
|
||||||
|
|
||||||
|
// Number of hashes in the proof (varint, but an O(logN) proof will never get bigger than 127)
|
||||||
|
data.append(1, static_cast<char>(coinbase_merkle_proof.size() / HASH_SIZE));
|
||||||
|
|
||||||
|
// Hashes in the proof
|
||||||
|
data.append(reinterpret_cast<const char*>(coinbase_merkle_proof.data()), coinbase_merkle_proof.size());
|
||||||
|
|
||||||
|
// Path bitmap (always 0 for the coinbase tx)
|
||||||
|
data.append(1, 0);
|
||||||
|
|
||||||
|
// TODO: serialize coinbase_tx_hasher, coinbase_tx_extra, aux_chain_merkle_proof
|
||||||
|
|
||||||
pow->set_pow_data(data);
|
pow->set_pow_data(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
~MergeMiningClientTari() override;
|
~MergeMiningClientTari() override;
|
||||||
|
|
||||||
bool get_params(ChainParameters& out_params) const override;
|
bool get_params(ChainParameters& out_params) const override;
|
||||||
void submit_solution(const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof) override;
|
void submit_solution(const BlockTemplate* block_tpl, const uint8_t (&hashing_blob)[128], size_t nonce_offset, const hash& seed_hash, const std::vector<uint8_t>& blob, const std::vector<hash>& merkle_proof) override;
|
||||||
|
|
||||||
static constexpr char TARI_PREFIX[] = "tari://";
|
static constexpr char TARI_PREFIX[] = "tari://";
|
||||||
|
|
||||||
|
|
|
@ -679,7 +679,7 @@ void p2pool::submit_aux_block(const hash& chain_id, uint32_t template_id, uint32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c->submit_solution(hashing_blob, nonce_offset, seed_hash, blob, proof);
|
c->submit_solution(block_tpl, hashing_blob, nonce_offset, seed_hash, blob, proof);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOGWARN(3, "submit_aux_block: failed to get merkle proof for chain_id " << chain_id);
|
LOGWARN(3, "submit_aux_block: failed to get merkle proof for chain_id " << chain_id);
|
||||||
|
|
Loading…
Reference in a new issue