Skip to content
Permalink
Browse files

close the database before DestroyDB

  • Loading branch information
xuanyan0x7c7 committed Nov 14, 2019
1 parent e0459e3 commit 8c74f93ba7a1c7045761fa6b434b08f637df1a71
Showing with 11 additions and 2 deletions.
  1. +11 −0 src/qtum/storageresults.cpp
  2. +0 −2 src/qtum/storageresults.h
@@ -3,6 +3,7 @@

StorageResults::StorageResults(std::string const& _path){
path = _path + "/resultsDB";
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, path, &db);
assert(status.ok());
@@ -25,7 +26,17 @@ void StorageResults::clearCacheResult(){

void StorageResults::wipeResults(){
LogPrintf("Wiping LevelDB in %s\n", path);
bool opened = db;
if (opened) {
delete db;
}
leveldb::Status result = leveldb::DestroyDB(path, leveldb::Options());
if (opened) {
leveldb::Options options;
options.create_if_missing = true;
leveldb::Status status = leveldb::DB::Open(options, path, &db);
assert(status.ok());
}
}

void StorageResults::deleteResults(std::vector<CTransactionRef> const& txs){
@@ -70,7 +70,5 @@ class StorageResults{

leveldb::DB* db;

leveldb::Options options;

std::unordered_map<dev::h256, std::vector<TransactionReceiptInfo>> m_cache_result;
};

0 comments on commit 8c74f93

Please sign in to comment.
You can’t perform that action at this time.