From 20e01b1a03819d843a860284033b48a5e3b65ff7 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 19 Sep 2014 19:21:46 +0200 Subject: Apply clang-format on some infrequently-updated files --- src/db.h | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'src/db.h') diff --git a/src/db.h b/src/db.h index eab27f43af..d202399383 100644 --- a/src/db.h +++ b/src/db.h @@ -54,7 +54,9 @@ public: * This must be called BEFORE strFile is opened. * Returns true if strFile is OK. */ - enum VerifyResult { VERIFY_OK, RECOVER_OK, RECOVER_FAIL }; + enum VerifyResult { VERIFY_OK, + RECOVER_OK, + RECOVER_FAIL }; VerifyResult Verify(std::string strFile, bool (*recoverFunc)(CDBEnv& dbenv, std::string strFile)); /* * Salvage data from a file that Verify says is bad. @@ -66,7 +68,7 @@ public: typedef std::pair, std::vector > KeyValPair; bool Salvage(std::string strFile, bool fAggressive, std::vector& vResult); - bool Open(const boost::filesystem::path &path); + bool Open(const boost::filesystem::path& path); void Close(); void Flush(bool fShutdown); void CheckpointLSN(const std::string& strFile); @@ -74,7 +76,7 @@ public: void CloseDb(const std::string& strFile); bool RemoveDb(const std::string& strFile); - DbTxn *TxnBegin(int flags=DB_TXN_WRITE_NOSYNC) + DbTxn* TxnBegin(int flags = DB_TXN_WRITE_NOSYNC) { DbTxn* ptxn = NULL; int ret = dbenv.txn_begin(NULL, &ptxn, flags); @@ -93,10 +95,10 @@ class CDB protected: Db* pdb; std::string strFile; - DbTxn *activeTxn; + DbTxn* activeTxn; bool fReadOnly; - explicit CDB(const std::string& strFilename, const char* pszMode="r+"); + explicit CDB(const std::string& strFilename, const char* pszMode = "r+"); ~CDB() { Close(); } public: @@ -108,7 +110,7 @@ private: void operator=(const CDB&); protected: - template + template bool Read(const K& key, T& value) { if (!pdb) @@ -132,8 +134,7 @@ protected: try { CDataStream ssValue((char*)datValue.get_data(), (char*)datValue.get_data() + datValue.get_size(), SER_DISK, CLIENT_VERSION); ssValue >> value; - } - catch (const std::exception &) { + } catch (const std::exception&) { return false; } @@ -143,8 +144,8 @@ protected: return (ret == 0); } - template - bool Write(const K& key, const T& value, bool fOverwrite=true) + template + bool Write(const K& key, const T& value, bool fOverwrite = true) { if (!pdb) return false; @@ -172,7 +173,7 @@ protected: return (ret == 0); } - template + template bool Erase(const K& key) { if (!pdb) @@ -194,7 +195,7 @@ protected: return (ret == 0 || ret == DB_NOTFOUND); } - template + template bool Exists(const K& key) { if (!pdb) @@ -225,18 +226,16 @@ protected: return pcursor; } - int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags=DB_NEXT) + int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags = DB_NEXT) { // Read at cursor Dbt datKey; - if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) - { + if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) { datKey.set_data(&ssKey[0]); datKey.set_size(ssKey.size()); } Dbt datValue; - if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) - { + if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) { datValue.set_data(&ssValue[0]); datValue.set_size(ssValue.size()); } -- cgit v1.2.3