mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
validation: rename snapshot chainstate dir
This changes the snapshot's leveldb chainstate dir name from `chainstate_[blockhash]` to `chainstate_snapshot`. This simplifies later logic that loads snapshot data, and enforces the limitation of a single snapshot at any given time. Since we still need to persis the blockhash of the base block, we write that out to a file (`chainstate_snapshot/base_blockhash`) for later use during initialization, so that we can reinitialize the snapshot chainstate. Co-authored-by: Russell Yanofsky <russ@yanofsky.org>
This commit is contained in:
parent
d14bebf100
commit
f9f1735f13
7 changed files with 134 additions and 6 deletions
|
|
@ -1515,7 +1515,7 @@ void Chainstate::InitCoinsDB(
|
|||
fs::path leveldb_name)
|
||||
{
|
||||
if (m_from_snapshot_blockhash) {
|
||||
leveldb_name += "_" + m_from_snapshot_blockhash->ToString();
|
||||
leveldb_name += node::SNAPSHOT_CHAINSTATE_SUFFIX;
|
||||
}
|
||||
|
||||
m_coins_views = std::make_unique<CoinsViews>(
|
||||
|
|
@ -4837,9 +4837,17 @@ bool ChainstateManager::ActivateSnapshot(
|
|||
static_cast<size_t>(current_coinstip_cache_size * SNAPSHOT_CACHE_PERC));
|
||||
}
|
||||
|
||||
const bool snapshot_ok = this->PopulateAndValidateSnapshot(
|
||||
bool snapshot_ok = this->PopulateAndValidateSnapshot(
|
||||
*snapshot_chainstate, coins_file, metadata);
|
||||
|
||||
// If not in-memory, persist the base blockhash for use during subsequent
|
||||
// initialization.
|
||||
if (!in_memory) {
|
||||
LOCK(::cs_main);
|
||||
if (!node::WriteSnapshotBaseBlockhash(*snapshot_chainstate)) {
|
||||
snapshot_ok = false;
|
||||
}
|
||||
}
|
||||
if (!snapshot_ok) {
|
||||
WITH_LOCK(::cs_main, this->MaybeRebalanceCaches());
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue