Merge ElementsProject/elements#1009: Fix dynafed logging to not duplicate messages

b5424e9987 Fix dynafed logging to not duplicate messages (Steven Roose)

Pull request description:

  This brings it up to date with the fixed forward port in https://github.com/ElementsProject/elements/pull/996.

Top commit has no ACKs.

Tree-SHA512: 9606ea46973bb5eceadf133b2c75e6ca98c4eb70fa821429ed3e3a06bc94d2c22f6e119b73cc458e5e040df775b64580767d7fe0234081ffcedacf51be4ac97f
This commit is contained in:
Andrew Poelstra 2021-09-10 13:17:54 +00:00
commit 07239d100b
No known key found for this signature in database
GPG key ID: C588D63CE41B97C1

View file

@ -2493,6 +2493,17 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
LogPrintf(" warning='%s'", warningMessages); /* Continued */
LogPrintf("\n");
// Do some logging if dynafed parameters changed.
if (pindexNew->pprev && !pindexNew->dynafed_params.IsNull()) {
int height = pindexNew->nHeight;
uint256 hash = pindexNew->GetBlockHash();
uint256 root = pindexNew->dynafed_params.m_current.CalculateRoot();
if (pindexNew->pprev->dynafed_params.IsNull()) {
LogPrintf("Dynafed activated in block %d:%s: %s\n", height, hash.GetHex(), root.GetHex());
} else if (root != pindexNew->pprev->dynafed_params.m_current.CalculateRoot()) {
LogPrintf("New dynafed parameters activated in block %d:%s: %s\n", height, hash.GetHex(), root.GetHex());
}
}
}
/** Disconnect chainActive's tip.
@ -3592,19 +3603,6 @@ static bool ContextualCheckDynaFedHeader(const CBlockHeader& block, CValidationS
}
}
// Do some logging if parameters changed.
auto parent = pindexPrev->dynafed_params.m_current;
if (dynafed_params.m_current != parent) {
int height = pindexPrev->nHeight + 1;
std::string hash = block.GetHash().GetHex();
std::string root = dynafed_params.m_current.CalculateRoot().GetHex();
if (parent.IsNull()) {
LogPrintf("Dynafed activated in block %d:%s: %s\n", height, hash, root);
} else {
LogPrintf("New dynafed parameters activated in block %d:%s: %s\n", height, hash, root);
}
}
return true;
}