diff options
Diffstat (limited to 'src/leveldbwrapper.cpp')
-rw-r--r-- | src/leveldbwrapper.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/leveldbwrapper.cpp b/src/leveldbwrapper.cpp index 9e849696a8..8ce3e7b470 100644 --- a/src/leveldbwrapper.cpp +++ b/src/leveldbwrapper.cpp @@ -12,7 +12,8 @@ #include <leveldb/filter_policy.h> #include <memenv.h> -void HandleError(const leveldb::Status &status) throw(leveldb_error) { +void HandleError(const leveldb::Status& status) throw(leveldb_error) +{ if (status.ok()) return; LogPrintf("%s\n", status.ToString()); @@ -25,7 +26,8 @@ void HandleError(const leveldb::Status &status) throw(leveldb_error) { throw leveldb_error("Unknown database error"); } -static leveldb::Options GetOptions(size_t nCacheSize) { +static leveldb::Options GetOptions(size_t nCacheSize) +{ leveldb::Options options; options.block_cache = leveldb::NewLRUCache(nCacheSize / 2); options.write_buffer_size = nCacheSize / 4; // up to two write buffers may be held in memory simultaneously @@ -40,7 +42,8 @@ static leveldb::Options GetOptions(size_t nCacheSize) { return options; } -CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path &path, size_t nCacheSize, bool fMemory, bool fWipe) { +CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path& path, size_t nCacheSize, bool fMemory, bool fWipe) +{ penv = NULL; readoptions.verify_checksums = true; iteroptions.verify_checksums = true; @@ -64,7 +67,8 @@ CLevelDBWrapper::CLevelDBWrapper(const boost::filesystem::path &path, size_t nCa LogPrintf("Opened LevelDB successfully\n"); } -CLevelDBWrapper::~CLevelDBWrapper() { +CLevelDBWrapper::~CLevelDBWrapper() +{ delete pdb; pdb = NULL; delete options.filter_policy; @@ -75,7 +79,8 @@ CLevelDBWrapper::~CLevelDBWrapper() { options.env = NULL; } -bool CLevelDBWrapper::WriteBatch(CLevelDBBatch &batch, bool fSync) throw(leveldb_error) { +bool CLevelDBWrapper::WriteBatch(CLevelDBBatch& batch, bool fSync) throw(leveldb_error) +{ leveldb::Status status = pdb->Write(fSync ? syncoptions : writeoptions, &batch.batch); HandleError(status); return true; |