| 6364 | } |
| 6365 | |
| 6366 | std::pair<int, int> Chainstate::GetPruneRange(int last_height_can_prune) const |
| 6367 | { |
| 6368 | if (m_chain.Height() <= 0) { |
| 6369 | return {0, 0}; |
| 6370 | } |
| 6371 | int prune_start{0}; |
| 6372 | |
| 6373 | if (m_from_snapshot_blockhash && m_assumeutxo != Assumeutxo::VALIDATED) { |
| 6374 | // Only prune blocks _after_ the snapshot if this is a snapshot chain |
| 6375 | // that has not been fully validated yet. The earlier blocks need to be |
| 6376 | // kept to validate the snapshot |
| 6377 | prune_start = Assert(SnapshotBase())->nHeight + 1; |
| 6378 | } |
| 6379 | |
| 6380 | int max_prune = std::max<int>( |
| 6381 | 0, m_chain.Height() - static_cast<int>(MIN_BLOCKS_TO_KEEP)); |
| 6382 | |
| 6383 | // last block to prune is the lesser of (caller-specified height, MIN_BLOCKS_TO_KEEP from the tip) |
| 6384 | // |
| 6385 | // While you might be tempted to prune the background chainstate more |
| 6386 | // aggressively (i.e. fewer MIN_BLOCKS_TO_KEEP), this won't work with index |
| 6387 | // building - specifically blockfilterindex requires undo data, and if |
| 6388 | // we don't maintain this trailing window, we hit indexing failures. |
| 6389 | int prune_end = std::min(last_height_can_prune, max_prune); |
| 6390 | |
| 6391 | return {prune_start, prune_end}; |
| 6392 | } |
| 6393 | |
| 6394 | std::optional<std::pair<const CBlockIndex*, const CBlockIndex*>> ChainstateManager::GetHistoricalBlockRange() const |
| 6395 | { |
no test coverage detected