@@ -691,6 +691,16 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
691
691
CCoinsViewCache *pcoinsTip = NULL ;
692
692
CBlockTreeDB *pblocktree = NULL ;
693
693
694
+ enum FlushStateMode {
695
+ FLUSH_STATE_NONE,
696
+ FLUSH_STATE_IF_NEEDED,
697
+ FLUSH_STATE_PERIODIC,
698
+ FLUSH_STATE_ALWAYS
699
+ };
700
+
701
+ // See definition for documentation
702
+ bool static FlushStateToDisk (CValidationState &state, FlushStateMode mode);
703
+
694
704
// ////////////////////////////////////////////////////////////////////////////
695
705
//
696
706
// mapOrphanTransactions
@@ -1581,6 +1591,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
1581
1591
BOOST_FOREACH (const uint256& hashTx, vHashTxToUncache)
1582
1592
pcoinsTip->Uncache (hashTx);
1583
1593
}
1594
+ // After we've (potentially) uncached entries, ensure our coins cache is still within its size limits
1595
+ CValidationState stateDummy;
1596
+ FlushStateToDisk (stateDummy, FLUSH_STATE_PERIODIC);
1584
1597
return res;
1585
1598
}
1586
1599
@@ -2558,13 +2571,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
2558
2571
return true ;
2559
2572
}
2560
2573
2561
- enum FlushStateMode {
2562
- FLUSH_STATE_NONE,
2563
- FLUSH_STATE_IF_NEEDED,
2564
- FLUSH_STATE_PERIODIC,
2565
- FLUSH_STATE_ALWAYS
2566
- };
2567
-
2568
2574
/* *
2569
2575
* Update the on-disk chain state.
2570
2576
* The caches and indexes are flushed depending on the mode we're called with
@@ -5684,7 +5690,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
5684
5690
Misbehaving (pfrom->GetId (), nDoS);
5685
5691
}
5686
5692
}
5687
- FlushStateToDisk (state, FLUSH_STATE_PERIODIC);
5688
5693
}
5689
5694
5690
5695
0 commit comments