| 52 | } |
| 53 | |
| 54 | CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe) { |
| 55 | penv = nullptr; |
| 56 | readoptions.verify_checksums = true; |
| 57 | iteroptions.verify_checksums = true; |
| 58 | iteroptions.fill_cache = false; |
| 59 | syncoptions.sync = true; |
| 60 | options = GetOptions(nCacheSize); |
| 61 | options.create_if_missing = true; |
| 62 | if (fMemory) { |
| 63 | penv = leveldb::NewMemEnv(leveldb::Env::Default()); |
| 64 | options.env = penv; |
| 65 | } else { |
| 66 | if (fWipe) { |
| 67 | LogPrint(BCLog::INFO, "Wiping LevelDB in %s\n", path.string()); |
| 68 | leveldb::DestroyDB(path.string(), options); |
| 69 | } |
| 70 | TryCreateDirectory(path); |
| 71 | LogPrint(BCLog::INFO, "Opening LevelDB in %s\n", path.string()); |
| 72 | } |
| 73 | leveldb::Status status = leveldb::DB::Open(options, path.string(), &pdb); |
| 74 | ThrowError(status); |
| 75 | LogPrint(BCLog::INFO, "Opened LevelDB successfully\n"); |
| 76 | } |
| 77 | |
| 78 | CLevelDBWrapper::~CLevelDBWrapper() { |
| 79 | delete pdb; |
nothing calls this directly
no test coverage detected