Merge 6b826d5004 into merged_master (Elements PR #1225)

This commit is contained in:
Byron Hambly 2023-07-03 12:14:31 +00:00
commit d4f242b3c3
3 changed files with 12 additions and 8 deletions

View file

@ -214,6 +214,7 @@ protected:
std::optional<CScriptWitness> m_signblock_witness{};
bool m_trimmed{false};
bool m_trimmed_dynafed_block{false};
friend class CBlockTreeDB;
@ -224,6 +225,7 @@ public:
void trim() {
assert_untrimmed();
m_trimmed = true;
m_trimmed_dynafed_block = !m_dynafed_params.value().IsNull();
proof = std::nullopt;
m_dynafed_params = std::nullopt;
m_signblock_witness = std::nullopt;
@ -242,6 +244,13 @@ public:
return proof.value();
}
const bool dynafed_block() const {
if (m_trimmed) {
return m_trimmed_dynafed_block;
}
return !m_dynafed_params.value().IsNull();
}
const DynaFedParams& dynafed_params() const {
assert_untrimmed();
return m_dynafed_params.value();

View file

@ -215,7 +215,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
result.pushKV("difficulty", GetDifficulty(blockindex));
result.pushKV("chainwork", blockindex->nChainWork.GetHex());
} else {
if (blockindex->dynafed_params().IsNull()) {
if (!blockindex->dynafed_block()) {
if (blockindex->trimmed()) {
result.pushKV("signblock_witness_asm", "<trimmed>");
result.pushKV("signblock_witness_hex", "<trimmed>");
@ -247,13 +247,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, TxVerbosity verbosity)
{
UniValue result;
if (blockindex->trimmed()) {
CBlockIndex tmp = CBlockIndex(block.GetBlockHeader());
result = blockheaderToJSON(tip, &tmp);
} else {
result = blockheaderToJSON(tip, blockindex);
}
UniValue result = blockheaderToJSON(tip, blockindex);
result.pushKV("strippedsize", (int)::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS));
result.pushKV("size", (int)::GetSerializeSize(block, PROTOCOL_VERSION));

View file

@ -412,6 +412,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
}
} else {
pindexNew->m_trimmed = true;
pindexNew->m_trimmed_dynafed_block = !diskindex.m_dynafed_params.value().IsNull();
}
pcursor->Next();