HF: Dyanfed pruned header now has extra root

This commit is contained in:
Gregory Sanders 2019-11-07 12:07:16 -05:00
parent 08023b0b4e
commit 1d7847305c
7 changed files with 58 additions and 21 deletions

View file

@ -43,19 +43,39 @@ std::string CBlock::ToString() const
uint256 DynaFedParamEntry::CalculateRoot() const
{
if (IsNull()) {
if (m_serialize_type == 0) {
return uint256();
}
std::vector<uint256> compact_leaves;
compact_leaves.push_back(SerializeHash(m_signblockscript, SER_GETHASH, 0));
compact_leaves.push_back(SerializeHash(m_signblock_witness_limit, SER_GETHASH, 0));
uint256 compact_root(ComputeFastMerkleRoot(compact_leaves));
uint256 extra_root;
if (m_serialize_type ==1 ) {
// It's pruned, take the stored value
extra_root = m_elided_root;
} else if (m_serialize_type == 2) {
// It's unpruned, compute the node value
extra_root = CalculateExtraRoot();
}
std::vector<uint256> leaves;
leaves.push_back(SerializeHash(m_signblockscript, SER_GETHASH, 0));
leaves.push_back(SerializeHash(m_signblock_witness_limit, SER_GETHASH, 0));
leaves.push_back(SerializeHash(m_fedpeg_program, SER_GETHASH, 0));
leaves.push_back(SerializeHash(m_fedpegscript, SER_GETHASH, 0));
leaves.push_back(SerializeHash(m_extension_space, SER_GETHASH, 0));
leaves.push_back(compact_root);
leaves.push_back(extra_root);
return ComputeFastMerkleRoot(leaves);
}
uint256 DynaFedParamEntry::CalculateExtraRoot() const
{
std::vector<uint256> extra_leaves;
extra_leaves.push_back(SerializeHash(m_fedpeg_program, SER_GETHASH, 0));
extra_leaves.push_back(SerializeHash(m_fedpegscript, SER_GETHASH, 0));
extra_leaves.push_back(SerializeHash(m_extension_space, SER_GETHASH, 0));
return ComputeFastMerkleRoot(extra_leaves);
}
uint256 DynaFedParams::CalculateRoot() const
{
if (IsNull()) {