MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / DeleteChainstate

Method DeleteChainstate

src/validation.cpp:6252–6268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6250}
6251
6252bool ChainstateManager::DeleteChainstate(Chainstate& chainstate)
6253{
6254 AssertLockHeld(::cs_main);
6255 assert(!chainstate.m_coins_views);
6256 const fs::path db_path{chainstate.StoragePath()};
6257 if (!DeleteCoinsDBFromDisk(db_path, /*is_snapshot=*/bool{chainstate.m_from_snapshot_blockhash})) {
6258 LogError("Deletion of %s failed. Please remove it manually to continue reindexing.",
6259 fs::PathToString(db_path));
6260 return false;
6261 }
6262 std::unique_ptr<Chainstate> prev_chainstate{Assert(RemoveChainstate(chainstate))};
6263 Chainstate& curr_chainstate{CurrentChainstate()};
6264 assert(prev_chainstate->m_mempool->size() == 0);
6265 assert(!curr_chainstate.m_mempool);
6266 std::swap(curr_chainstate.m_mempool, prev_chainstate->m_mempool);
6267 return true;
6268}
6269
6270ChainstateRole Chainstate::GetRole() const
6271{

Callers 1

LoadChainstateFunction · 0.80

Calls 3

PathToStringFunction · 0.85
StoragePathMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected