Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1501impl->mem_->Ref();1502}1503}1504if (s.ok() && save_manifest) {1505edit.SetPrevLogNumber(0); // No older logs needed after recovery.1506edit.SetLogNumber(impl->logfile_number_);1507s = impl->versions_->LogAndApply(&edit, &impl->mutex_);1508}1509if (s.ok()) {1510impl->DeleteObsoleteFiles();1511impl->MaybeScheduleCompaction();1512}1513impl->mutex_.Unlock();1514if (s.ok()) {1515assert(impl->mem_ != nullptr);1516*dbptr = impl;1517} else {1518delete impl;1519}1520return s;1521}1523Snapshot::~Snapshot() = default;1525Status DestroyDB(const std::string& dbname, const Options& options) {1526Env* env = options.env;1527std::vector<std::string> filenames;1528Status result = env->GetChildren(dbname, &filenames);1529if (!result.ok()) {1530// Ignore error in case directory does not exist1531return Status::OK();1532}1534FileLock* lock;1535const std::string lockname = LockFileName(dbname);1536result = env->LockFile(lockname, &lock);1537if (result.ok()) {1538uint64_t number;1539FileType type;1540for (size_t i = 0; i < filenames.size(); i++) {1541if (ParseFileName(filenames[i], &number, &type) &&1542type != kDBLockFile) { // Lock file will be deleted at end1543Status del = env->DeleteFile(dbname + "/" + filenames[i]);1544if (result.ok() && !del.ok()) {1545result = del;1546}1547}1548}1549env->UnlockFile(lock); // Ignore error since state is already gone1550env->DeleteFile(lockname);1551env->DeleteDir(dbname); // Ignore error in case dir contains other files1552}1553return result;1554}1556} // namespace leveldb
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.