MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / CLevelDBWrapper

Method CLevelDBWrapper

src/persistence/leveldbwrapper.cpp:54–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54CLevelDBWrapper::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
78CLevelDBWrapper::~CLevelDBWrapper() {
79 delete pdb;

Callers

nothing calls this directly

Calls 5

GetOptionsFunction · 0.85
NewMemEnvFunction · 0.85
DestroyDBFunction · 0.85
TryCreateDirectoryFunction · 0.85
ThrowErrorFunction · 0.85

Tested by

no test coverage detected