Skip to content

Commit d4f242b

Browse files
committed
Merge 6b826d5 into merged_master (Elements PR ElementsProject#1225)
2 parents 2d596f1 + 6b826d5 commit d4f242b

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/chain.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class CBlockIndex
214214
std::optional<CScriptWitness> m_signblock_witness{};
215215

216216
bool m_trimmed{false};
217+
bool m_trimmed_dynafed_block{false};
217218

218219
friend class CBlockTreeDB;
219220

@@ -224,6 +225,7 @@ class CBlockIndex
224225
void trim() {
225226
assert_untrimmed();
226227
m_trimmed = true;
228+
m_trimmed_dynafed_block = !m_dynafed_params.value().IsNull();
227229
proof = std::nullopt;
228230
m_dynafed_params = std::nullopt;
229231
m_signblock_witness = std::nullopt;
@@ -242,6 +244,13 @@ class CBlockIndex
242244
return proof.value();
243245
}
244246

247+
const bool dynafed_block() const {
248+
if (m_trimmed) {
249+
return m_trimmed_dynafed_block;
250+
}
251+
return !m_dynafed_params.value().IsNull();
252+
}
253+
245254
const DynaFedParams& dynafed_params() const {
246255
assert_untrimmed();
247256
return m_dynafed_params.value();

src/rpc/blockchain.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
215215
result.pushKV("difficulty", GetDifficulty(blockindex));
216216
result.pushKV("chainwork", blockindex->nChainWork.GetHex());
217217
} else {
218-
if (blockindex->dynafed_params().IsNull()) {
218+
if (!blockindex->dynafed_block()) {
219219
if (blockindex->trimmed()) {
220220
result.pushKV("signblock_witness_asm", "<trimmed>");
221221
result.pushKV("signblock_witness_hex", "<trimmed>");
@@ -247,13 +247,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
247247

248248
UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, TxVerbosity verbosity)
249249
{
250-
UniValue result;
251-
if (blockindex->trimmed()) {
252-
CBlockIndex tmp = CBlockIndex(block.GetBlockHeader());
253-
result = blockheaderToJSON(tip, &tmp);
254-
} else {
255-
result = blockheaderToJSON(tip, blockindex);
256-
}
250+
UniValue result = blockheaderToJSON(tip, blockindex);
257251

258252
result.pushKV("strippedsize", (int)::GetSerializeSize(block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS));
259253
result.pushKV("size", (int)::GetSerializeSize(block, PROTOCOL_VERSION));

src/txdb.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams,
412412
}
413413
} else {
414414
pindexNew->m_trimmed = true;
415+
pindexNew->m_trimmed_dynafed_block = !diskindex.m_dynafed_params.value().IsNull();
415416
}
416417

417418
pcursor->Next();

0 commit comments

Comments
 (0)