mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
Relocate calls to CheckDiskSpace
Make sure we're checking disk space for block index writes and allow for pruning to happen before chainstate writes.
This commit is contained in:
parent
67708acff9
commit
86a5f4b54e
15
src/main.cpp
15
src/main.cpp
@ -1919,12 +1919,8 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
|
|||||||
bool fDoFullFlush = (mode == FLUSH_STATE_ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicFlush || fFlushForPrune;
|
bool fDoFullFlush = (mode == FLUSH_STATE_ALWAYS) || fCacheLarge || fCacheCritical || fPeriodicFlush || fFlushForPrune;
|
||||||
// Write blocks and block index to disk.
|
// Write blocks and block index to disk.
|
||||||
if (fDoFullFlush || fPeriodicWrite) {
|
if (fDoFullFlush || fPeriodicWrite) {
|
||||||
// Typical CCoins structures on disk are around 128 bytes in size.
|
// Depend on nMinDiskSpace to ensure we can write block index
|
||||||
// Pushing a new one to the database can cause it to be written
|
if (!CheckDiskSpace(0))
|
||||||
// twice (once in the log, and once in the tables). This is already
|
|
||||||
// an overestimation, as most will delete an existing entry or
|
|
||||||
// overwrite one. Still, use a conservative safety factor of 2.
|
|
||||||
if (fDoFullFlush && !CheckDiskSpace(128 * 2 * 2 * pcoinsTip->GetCacheSize()))
|
|
||||||
return state.Error("out of disk space");
|
return state.Error("out of disk space");
|
||||||
// First make sure all block and undo data is flushed to disk.
|
// First make sure all block and undo data is flushed to disk.
|
||||||
FlushBlockFile();
|
FlushBlockFile();
|
||||||
@ -1955,6 +1951,13 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
|
|||||||
}
|
}
|
||||||
// Flush best chain related state. This can only be done if the blocks / block index write was also done.
|
// Flush best chain related state. This can only be done if the blocks / block index write was also done.
|
||||||
if (fDoFullFlush) {
|
if (fDoFullFlush) {
|
||||||
|
// Typical CCoins structures on disk are around 128 bytes in size.
|
||||||
|
// Pushing a new one to the database can cause it to be written
|
||||||
|
// twice (once in the log, and once in the tables). This is already
|
||||||
|
// an overestimation, as most will delete an existing entry or
|
||||||
|
// overwrite one. Still, use a conservative safety factor of 2.
|
||||||
|
if (!CheckDiskSpace(128 * 2 * 2 * pcoinsTip->GetCacheSize()))
|
||||||
|
return state.Error("out of disk space");
|
||||||
// Flush the chainstate (which may refer to block index entries).
|
// Flush the chainstate (which may refer to block index entries).
|
||||||
if (!pcoinsTip->Flush())
|
if (!pcoinsTip->Flush())
|
||||||
return state.Abort("Failed to write to coin database");
|
return state.Abort("Failed to write to coin database");
|
||||||
|
Loading…
Reference in New Issue
Block a user