Fixed block template generation

Mining with `--merge-mining` in the command line but with merge mining disabled was broken
This commit is contained in:
SChernykh 2024-05-23 22:17:39 +02:00
parent 3d85ee847c
commit d0107ed148

View file

@ -669,8 +669,14 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
m_poolBlockTemplate->m_sidechainId = {};
m_poolBlockTemplate->m_merkleRoot = {};
if (m_poolBlockTemplate->merge_mining_enabled()) {
m_poolBlockTemplate->m_auxChains = data.aux_chains;
m_poolBlockTemplate->m_auxNonce = data.aux_nonce;
}
else {
m_poolBlockTemplate->m_auxChains.clear();
m_poolBlockTemplate->m_auxNonce = 0;
}
init_merge_mining_merkle_proof();
@ -705,8 +711,8 @@ void BlockTemplate::update(const MinerData& data, const Mempool& mempool, const
m_poolBlockTemplate->m_sidechainId = calc_sidechain_hash(0);
{
const uint32_t n_aux_chains = static_cast<uint32_t>(data.aux_chains.size() + 1);
const uint32_t aux_slot = get_aux_slot(m_sidechain->consensus_hash(), data.aux_nonce, n_aux_chains);
const uint32_t n_aux_chains = static_cast<uint32_t>(m_poolBlockTemplate->m_auxChains.size() + 1);
const uint32_t aux_slot = get_aux_slot(m_sidechain->consensus_hash(), m_poolBlockTemplate->m_auxNonce, n_aux_chains);
m_poolBlockTemplate->m_merkleRoot = get_root_from_proof(m_poolBlockTemplate->m_sidechainId, m_poolBlockTemplate->m_merkleProof, aux_slot, n_aux_chains);
}