diff options
| author | Matt Corallo <[email protected]> | 2016-10-03 10:06:10 -0400 |
|---|---|---|
| committer | Matt Corallo <[email protected]> | 2016-10-31 10:08:11 -0400 |
| commit | 65f35eb91b4ad11c96703150b202c1e9b9d12266 (patch) | |
| tree | 821aa64a87939a5148af46e0e4944ff2e47f77ba /src/main.cpp | |
| parent | Merge #9033: Update build notes for dropping osx 10.7 support (fanquake) (diff) | |
| download | discoin-65f35eb91b4ad11c96703150b202c1e9b9d12266.tar.xz discoin-65f35eb91b4ad11c96703150b202c1e9b9d12266.zip | |
Move FlushStateToDisk call out of ProcessMessages::TX into ATMP
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp index 5e17ec625..83e85f3d2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -691,6 +691,16 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc CCoinsViewCache *pcoinsTip = NULL; CBlockTreeDB *pblocktree = NULL; +enum FlushStateMode { + FLUSH_STATE_NONE, + FLUSH_STATE_IF_NEEDED, + FLUSH_STATE_PERIODIC, + FLUSH_STATE_ALWAYS +}; + +// See definition for documentation +bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode); + ////////////////////////////////////////////////////////////////////////////// // // mapOrphanTransactions @@ -1581,6 +1591,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa BOOST_FOREACH(const uint256& hashTx, vHashTxToUncache) pcoinsTip->Uncache(hashTx); } + // After we've (potentially) uncached entries, ensure our coins cache is still within its size limits + CValidationState stateDummy; + FlushStateToDisk(stateDummy, FLUSH_STATE_PERIODIC); return res; } @@ -2558,13 +2571,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return true; } -enum FlushStateMode { - FLUSH_STATE_NONE, - FLUSH_STATE_IF_NEEDED, - FLUSH_STATE_PERIODIC, - FLUSH_STATE_ALWAYS -}; - /** * Update the on-disk chain state. * 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, Misbehaving(pfrom->GetId(), nDoS); } } - FlushStateToDisk(state, FLUSH_STATE_PERIODIC); } |