Merge pull request #1256 from psgreco/master-trim-v2-prep

Small fixes in preparation for trim_headers version 2
This commit is contained in:
Jeff Frontz 2023-08-23 19:42:07 -04:00 committed by GitHub
commit 7d9dade900
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -217,11 +217,11 @@ public:
m_signblock_witness = std::nullopt;
}
bool trimmed() const {
inline bool trimmed() const {
return m_trimmed;
}
void assert_untrimmed() const {
inline void assert_untrimmed() const {
assert(!m_trimmed);
}
@ -230,7 +230,7 @@ public:
return proof.value();
}
const bool dynafed_block() const {
bool is_dynafed_block() const {
if (m_trimmed) {
return m_trimmed_dynafed_block;
}
@ -417,12 +417,12 @@ public:
nVersion = ~CBlockHeader::DYNAFED_HF_MASK & nVersion;
return is_dyna;
} else {
return !dynafed_params().IsNull();
return is_dynafed_block();
}
}
bool RemoveDynaFedMaskOnSerialize(bool for_read) const {
assert(!for_read);
return !dynafed_params().IsNull();
return is_dynafed_block();
}
SERIALIZE_METHODS(CDiskBlockIndex, obj)
@ -445,12 +445,12 @@ public:
READWRITE(obj.nVersion);
} else {
int32_t nVersion = obj.nVersion;
if (!obj.dynafed_params().IsNull()) {
if (obj.is_dynafed_block()) {
nVersion |= CBlockHeader::DYNAFED_HF_MASK;
}
READWRITE(nVersion);
}
bool is_dyna = obj.RemoveDynaFedMaskOnSerialize(ser_action.ForRead());;
bool is_dyna = obj.RemoveDynaFedMaskOnSerialize(ser_action.ForRead());
READWRITE(obj.hashPrev);
READWRITE(obj.hashMerkleRoot);

View file

@ -986,7 +986,7 @@ bool AppInitParameterInteraction(const ArgsManager& args)
epoch_length = 20160;
}
if (args.IsArgSet("-trim_headers")) {
if (args.GetBoolArg("-trim_headers", false)) {
LogPrintf("Configured for header-trimming mode. This will reduce memory usage substantially, but we will be unable to serve as a full P2P peer, and certain header fields may be missing from JSON RPC output.\n");
fTrimHeaders = true;
// This calculation is driven by GetValidFedpegScripts in pegins.cpp, which walks the chain

View file

@ -248,7 +248,7 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
result.pushKV("difficulty", GetDifficulty(blockindex));
result.pushKV("chainwork", blockindex->nChainWork.GetHex());
} else {
if (!blockindex->dynafed_block()) {
if (!blockindex->is_dynafed_block()) {
if (blockindex->trimmed()) {
result.pushKV("signblock_witness_asm", "<trimmed>");
result.pushKV("signblock_witness_hex", "<trimmed>");