Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 4,081 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* BLOCK PRUNING CODE | * BLOCK PRUNING CODE | ||||
*/ | */ | ||||
/** | /** | ||||
* Calculate the amount of disk space the block & undo files currently use. | * Calculate the amount of disk space the block & undo files currently use. | ||||
*/ | */ | ||||
static uint64_t CalculateCurrentUsage() { | uint64_t CalculateCurrentUsage() { | ||||
LOCK(cs_LastBlockFile); | |||||
uint64_t retval = 0; | uint64_t retval = 0; | ||||
for (const CBlockFileInfo &file : vinfoBlockFile) { | for (const CBlockFileInfo &file : vinfoBlockFile) { | ||||
retval += file.nSize + file.nUndoSize; | retval += file.nSize + file.nUndoSize; | ||||
} | } | ||||
return retval; | return retval; | ||||
} | } | ||||
/** | /** | ||||
* Prune a block file (modify associated database entries) | * Prune a block file (modify associated database entries) | ||||
*/ | */ | ||||
void PruneOneBlockFile(const int fileNumber) { | void PruneOneBlockFile(const int fileNumber) { | ||||
LOCK(cs_LastBlockFile); | |||||
for (const std::pair<const uint256, CBlockIndex *> &it : mapBlockIndex) { | for (const std::pair<const uint256, CBlockIndex *> &it : mapBlockIndex) { | ||||
CBlockIndex *pindex = it.second; | CBlockIndex *pindex = it.second; | ||||
if (pindex->nFile == fileNumber) { | if (pindex->nFile == fileNumber) { | ||||
pindex->nStatus = pindex->nStatus.withData(false).withUndo(false); | pindex->nStatus = pindex->nStatus.withData(false).withUndo(false); | ||||
pindex->nFile = 0; | pindex->nFile = 0; | ||||
pindex->nDataPos = 0; | pindex->nDataPos = 0; | ||||
pindex->nUndoPos = 0; | pindex->nUndoPos = 0; | ||||
setDirtyBlockIndex.insert(pindex); | setDirtyBlockIndex.insert(pindex); | ||||
▲ Show 20 Lines • Show All 1,294 Lines • ▼ Show 20 Lines | |||||
std::string CBlockFileInfo::ToString() const { | std::string CBlockFileInfo::ToString() const { | ||||
return strprintf( | return strprintf( | ||||
"CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", | "CBlockFileInfo(blocks=%u, size=%u, heights=%u...%u, time=%s...%s)", | ||||
nBlocks, nSize, nHeightFirst, nHeightLast, | nBlocks, nSize, nHeightFirst, nHeightLast, | ||||
FormatISO8601DateTime(nTimeFirst), FormatISO8601DateTime(nTimeLast)); | FormatISO8601DateTime(nTimeFirst), FormatISO8601DateTime(nTimeLast)); | ||||
} | } | ||||
CBlockFileInfo *GetBlockFileInfo(size_t n) { | CBlockFileInfo *GetBlockFileInfo(size_t n) { | ||||
LOCK(cs_LastBlockFile); | |||||
return &vinfoBlockFile.at(n); | return &vinfoBlockFile.at(n); | ||||
} | } | ||||
static const uint64_t MEMPOOL_DUMP_VERSION = 1; | static const uint64_t MEMPOOL_DUMP_VERSION = 1; | ||||
bool LoadMempool(const Config &config) { | bool LoadMempool(const Config &config) { | ||||
int64_t nExpiryTimeout = | int64_t nExpiryTimeout = | ||||
gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60; | gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60; | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |