Merge ElementsProject/elements#996: [forward port] Add logging for dynafed activation and transitions

0c9197e421 Add logging for dynafed activation and transitions (Steven Roose)

Pull request description:

  Forward port and fixup of https://github.com/ElementsProject/elements/pull/994.
  Closes https://github.com/ElementsProject/elements/issues/981.

ACKs for top commit:
  apoelstra:
    ACK 0c9197e421

Tree-SHA512: df0586bff24e0842de0df19ca67821cc51105c1d03d2d950db5e4f4577cf38b3faa1155cdaa30a23c858ad3e0b0351e48b38034758798fe4546b8baf8c6c9747
This commit is contained in:
Steven Roose 2021-09-08 14:07:07 +01:00
commit 9f34730d0f
No known key found for this signature in database
GPG key ID: 2F2A88D7F8D68E87

View file

@ -2695,6 +2695,18 @@ static void UpdateTip(CTxMemPool& mempool, const CBlockIndex* pindexNew, const C
if (num_unexpected_version > 0) {
LogPrint(BCLog::VALIDATION, "%d of last 100 blocks have unexpected version\n", num_unexpected_version);
}
// 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 m_chain's tip.