@@ -2348,6 +2348,7 @@ bool CChainState::FlushStateToDisk(
23482348 vBlocks.reserve (setDirtyBlockIndex.size ());
23492349 std::set<CBlockIndex*> setTrimmableBlockIndex (setDirtyBlockIndex);
23502350 for (std::set<CBlockIndex*>::iterator it = setDirtyBlockIndex.begin (); it != setDirtyBlockIndex.end (); ) {
2351+ (*it)->untrim ();
23512352 vBlocks.push_back (*it);
23522353 setDirtyBlockIndex.erase (it++);
23532354 }
@@ -2460,6 +2461,18 @@ static void AppendWarning(bilingual_str& res, const bilingual_str& warn)
24602461 res += warn;
24612462}
24622463
2464+ void ForceUntrimHeader (const CBlockIndex *pindex_)
2465+ {
2466+ assert (pindex_);
2467+ if (!pindex_->trimmed ()) {
2468+ return ;
2469+ }
2470+ AssertLockHeld (cs_main);
2471+ CBlockIndex* pindex = const_cast <CBlockIndex*>(pindex_);
2472+ pindex->untrim ();
2473+ setDirtyBlockIndex.insert (pindex);
2474+ }
2475+
24632476void CChainState::UpdateTip (const CBlockIndex* pindexNew)
24642477{
24652478 // New best block
@@ -2497,11 +2510,13 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew)
24972510 this ->CoinsTip ().DynamicMemoryUsage () * (1.0 / (1 <<20 )), this ->CoinsTip ().GetCacheSize (),
24982511 !warning_messages.empty () ? strprintf (" warning='%s'" , warning_messages.original ) : " " );
24992512
2513+ ForceUntrimHeader (pindexNew);
25002514 // Do some logging if dynafed parameters changed.
25012515 if (pindexNew->pprev && !pindexNew->dynafed_params ().IsNull ()) {
25022516 int height = pindexNew->nHeight ;
25032517 uint256 hash = pindexNew->GetBlockHash ();
25042518 uint256 root = pindexNew->dynafed_params ().m_current .CalculateRoot ();
2519+ ForceUntrimHeader (pindexNew->pprev );
25052520 if (pindexNew->pprev ->dynafed_params ().IsNull ()) {
25062521 LogPrintf (" Dynafed activated in block %d:%s: %s\n " , height, hash.GetHex (), root.GetHex ());
25072522 } else if (root != pindexNew->pprev ->dynafed_params ().m_current .CalculateRoot ()) {
0 commit comments