refactor: Delete ChainstateManager::GetAll() method

Just use m_chainstates array instead.
This commit is contained in:
Ryan Ofsky
2024-05-30 19:45:14 -04:00
parent 6a572dbda9
commit ae85c495f1
8 changed files with 95 additions and 80 deletions

View File

@@ -318,9 +318,16 @@ void BlockManager::FindFilesToPrune(
ChainstateManager& chainman)
{
LOCK2(cs_main, cs_LastBlockFile);
// Distribute our -prune budget over all chainstates.
// Compute `target` value with maximum size (in bytes) of blocks below the
// `last_prune` height which should be preserved and not pruned. The
// `target` value will be derived from the -prune preference provided by the
// user. If there is a historical chainstate being used to populate indexes
// and validate the snapshot, the target is divided by two so half of the
// block storage will be reserved for the historical chainstate, and the
// other half will be reserved for the most-work chainstate.
const int num_chainstates{chainman.HistoricalChainstate() ? 2 : 1};
const auto target = std::max(
MIN_DISK_SPACE_FOR_BLOCK_FILES, GetPruneTarget() / chainman.GetAll().size());
MIN_DISK_SPACE_FOR_BLOCK_FILES, GetPruneTarget() / num_chainstates);
const uint64_t target_sync_height = chainman.m_best_header->nHeight;
if (chain.m_chain.Height() < 0 || target == 0) {