Added hardfork code
This commit is contained in:
+28
-9
@@ -201,10 +201,18 @@ std::vector<uint8_t> PoolBlock::serialize_mainchain_data(size_t* header_size, si
|
||||
}
|
||||
|
||||
*(p++) = TX_EXTRA_MERGE_MINING_TAG;
|
||||
*(p++) = static_cast<uint8_t>(m_merkleTreeDataSize + HASH_SIZE);
|
||||
writeVarint(m_merkleTreeData, [&p](const uint8_t b) { *(p++) = b; });
|
||||
memcpy(p, m_merkleRoot.h, HASH_SIZE);
|
||||
p += HASH_SIZE;
|
||||
|
||||
if (!merge_mining_enabled()) {
|
||||
*(p++) = HASH_SIZE;
|
||||
memcpy(p, m_sidechainId.h, HASH_SIZE);
|
||||
p += HASH_SIZE;
|
||||
}
|
||||
else {
|
||||
*(p++) = static_cast<uint8_t>(m_merkleTreeDataSize + HASH_SIZE);
|
||||
writeVarint(m_merkleTreeData, [&p](const uint8_t b) { *(p++) = b; });
|
||||
memcpy(p, m_merkleRoot.h, HASH_SIZE);
|
||||
p += HASH_SIZE;
|
||||
}
|
||||
|
||||
writeVarint(static_cast<size_t>(p - tx_extra), data);
|
||||
data.insert(data.end(), tx_extra, p);
|
||||
@@ -257,12 +265,14 @@ std::vector<uint8_t> PoolBlock::serialize_sidechain_data() const
|
||||
writeVarint(m_cumulativeDifficulty.lo, data);
|
||||
writeVarint(m_cumulativeDifficulty.hi, data);
|
||||
|
||||
const uint8_t n = static_cast<uint8_t>(m_merkleProof.size());
|
||||
data.push_back(n);
|
||||
if (merge_mining_enabled()) {
|
||||
const uint8_t n = static_cast<uint8_t>(m_merkleProof.size());
|
||||
data.push_back(n);
|
||||
|
||||
for (uint8_t i = 0; i < n; ++i) {
|
||||
const hash& h = m_merkleProof[i];
|
||||
data.insert(data.end(), h.h, h.h + HASH_SIZE);
|
||||
for (uint8_t i = 0; i < n; ++i) {
|
||||
const hash& h = m_merkleProof[i];
|
||||
data.insert(data.end(), h.h, h.h + HASH_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
const uint8_t* p = reinterpret_cast<const uint8_t*>(m_sidechainExtraBuf);
|
||||
@@ -401,4 +411,13 @@ hash PoolBlock::calculate_tx_key_seed() const
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PoolBlock::merge_mining_enabled() const
|
||||
{
|
||||
#ifdef P2POOL_UNIT_TESTS
|
||||
return false;
|
||||
#else
|
||||
return (SideChain::network_type() != NetworkType::Mainnet) || (m_timestamp >= MERGE_MINING_FORK_TIME);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace p2pool
|
||||
|
||||
Reference in New Issue
Block a user