blockstorage: Add prune locks to BlockManager

This change also introduces an aditional buffer of 10 blocks (PRUNE_LOCK_BUFFER) that will not be pruned before the best block.

Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>
This commit is contained in:
Fabian Jahr
2021-05-13 19:13:08 +02:00
parent 231fc7b035
commit 2561823531
3 changed files with 60 additions and 3 deletions

View File

@@ -21,6 +21,8 @@
#include <util/system.h>
#include <validation.h>
#include <unordered_map>
namespace node {
std::atomic_bool fImporting(false);
std::atomic_bool fReindex(false);
@@ -230,6 +232,11 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
nLastBlockWeCanPrune, count);
}
void BlockManager::UpdatePruneLock(const std::string& name, const PruneLockInfo& lock_info) {
AssertLockHeld(::cs_main);
m_prune_locks[name] = lock_info;
}
CBlockIndex* BlockManager::InsertBlockIndex(const uint256& hash)
{
AssertLockHeld(cs_main);