Skip to content

Commit 65f35eb

Browse files
committed
Move FlushStateToDisk call out of ProcessMessages::TX into ATMP
1 parent 83234d4 commit 65f35eb

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/main.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,16 @@ CBlockIndex* FindForkInGlobalIndex(const CChain& chain, const CBlockLocator& loc
691691
CCoinsViewCache *pcoinsTip = NULL;
692692
CBlockTreeDB *pblocktree = NULL;
693693

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+
694704
//////////////////////////////////////////////////////////////////////////////
695705
//
696706
// mapOrphanTransactions
@@ -1581,6 +1591,9 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
15811591
BOOST_FOREACH(const uint256& hashTx, vHashTxToUncache)
15821592
pcoinsTip->Uncache(hashTx);
15831593
}
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);
15841597
return res;
15851598
}
15861599

@@ -2558,13 +2571,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
25582571
return true;
25592572
}
25602573

2561-
enum FlushStateMode {
2562-
FLUSH_STATE_NONE,
2563-
FLUSH_STATE_IF_NEEDED,
2564-
FLUSH_STATE_PERIODIC,
2565-
FLUSH_STATE_ALWAYS
2566-
};
2567-
25682574
/**
25692575
* Update the on-disk chain state.
25702576
* 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,
56845690
Misbehaving(pfrom->GetId(), nDoS);
56855691
}
56865692
}
5687-
FlushStateToDisk(state, FLUSH_STATE_PERIODIC);
56885693
}
56895694

56905695

0 commit comments

Comments
 (0)