9 #include <boost/filesystem.hpp>
10 #include <leveldb/cache.h>
11 #include <leveldb/env.h>
12 #include <leveldb/filter_policy.h>
19 if (status.IsCorruption())
21 if (status.IsIOError())
23 if (status.IsNotFound())
29 leveldb::Options options;
30 options.block_cache = leveldb::NewLRUCache(nCacheSize / 2);
31 options.write_buffer_size = nCacheSize / 4;
32 options.filter_policy = leveldb::NewBloomFilterPolicy(10);
33 options.compression = leveldb::kNoCompression;
34 options.max_open_files = 64;
45 options.create_if_missing =
true;
47 penv = leveldb::NewMemEnv(leveldb::Env::Default());
51 LogPrintf(
"Wiping LevelDB in %s\n", path.string());
52 leveldb::DestroyDB(path.string(),
options);
55 LogPrintf(
"Opening LevelDB in %s\n", path.string());
57 leveldb::Status status = leveldb::DB::Open(
options, path.string(), &
pdb);
59 LogPrintf(
"Opened LevelDB successfully\n");
74 leveldb::Status status = pdb->Write(fSync ? syncoptions : writeoptions, &batch.batch);
leveldb::WriteOptions syncoptions
static leveldb::Options GetOptions(size_t nCacheSize)
CLevelDBWrapper(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory=false, bool fWipe=false)
void HandleError(const leveldb::Status &status)
bool TryCreateDirectory(const boost::filesystem::path &p)
leveldb::ReadOptions iteroptions
bool WriteBatch(CLevelDBBatch &batch, bool fSync=false)
leveldb::ReadOptions readoptions