mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-13 03:30:42 +02:00
blockstorage: Add height_last to PruneLockInfo
This commit is contained in:
parent
64de1480d3
commit
1ebacb60f8
@ -31,6 +31,7 @@
|
||||
#include <util/batchpriority.h>
|
||||
#include <util/check.h>
|
||||
#include <util/fs.h>
|
||||
#include <util/overflow.h>
|
||||
#include <util/signalinterrupt.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/translation.h>
|
||||
@ -283,10 +284,13 @@ bool BlockManager::DoPruneLocksForbidPruning(const CBlockFileInfo& block_file_in
|
||||
if (prune_lock.second.height_first == std::numeric_limits<int>::max()) continue;
|
||||
// Remove the buffer and one additional block here to get actual height that is outside of the buffer
|
||||
const unsigned int lock_height{(unsigned)std::max(1, prune_lock.second.height_first - PRUNE_LOCK_BUFFER - 1)};
|
||||
if (block_file_info.nHeightLast > lock_height) {
|
||||
LogPrint(BCLog::PRUNE, "%s limited pruning to height %d\n", prune_lock.first, lock_height);
|
||||
return true;
|
||||
}
|
||||
const unsigned int lock_height_last{(unsigned)std::max(1, SaturatingAdd(prune_lock.second.height_last, PRUNE_LOCK_BUFFER))};
|
||||
if (block_file_info.nHeightFirst > lock_height_last) continue;
|
||||
if (block_file_info.nHeightLast <= lock_height) continue;
|
||||
// TODO: Check each block within the file against the prune_lock range
|
||||
|
||||
LogPrint(BCLog::PRUNE, "%s limited pruning to height %d\n", prune_lock.first, lock_height);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ struct CBlockIndexHeightOnlyComparator {
|
||||
|
||||
struct PruneLockInfo {
|
||||
int height_first{std::numeric_limits<int>::max()}; //! Height of earliest block that should be kept and not pruned
|
||||
int height_last{std::numeric_limits<int>::max()}; //! Height of latest block that should be kept and not pruned
|
||||
};
|
||||
|
||||
enum BlockfileType {
|
||||
@ -253,8 +254,9 @@ private:
|
||||
/**
|
||||
* Map from external index name to oldest block that must not be pruned.
|
||||
*
|
||||
* @note Internally, only blocks at height (height_first - PRUNE_LOCK_BUFFER - 1) and
|
||||
* below will be pruned, but callers should avoid assuming any particular buffer size.
|
||||
* @note Internally, only blocks before height (height_first - PRUNE_LOCK_BUFFER - 1) and
|
||||
* after height (height_last + PRUNE_LOCK_BUFFER) will be pruned, but callers should
|
||||
* avoid assuming any particular buffer size.
|
||||
*/
|
||||
std::unordered_map<std::string, PruneLockInfo> m_prune_locks GUARDED_BY(::cs_main);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user