X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fdb.h;h=8f6c42d7337af81544f241fe4a04ff8975d6251e;hb=b2de28c74040595fa3fe5353ea063a8c3874f6b1;hp=b9101112763549a3e33127f176c3be773a0558d3;hpb=7ec552676c66488fe00fb503d02ec4a389a715b7;p=novacoin.git diff --git a/src/db.h b/src/db.h index b910111..8f6c42d 100644 --- a/src/db.h +++ b/src/db.h @@ -1,6 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_DB_H #define BITCOIN_DB_H @@ -27,14 +28,12 @@ class CBlockLocator; extern unsigned int nWalletDBUpdated; extern DbEnv dbenv; - extern void DBFlush(bool fShutdown); void ThreadFlushWalletDB(void* parg); bool BackupWallet(const CWallet& wallet, const std::string& strDest); - class CDB { protected: @@ -88,7 +87,7 @@ protected: if (!pdb) return false; if (fReadOnly) - assert(("Write called on database in read-only mode", false)); + assert(!"Write called on database in read-only mode"); // Key CDataStream ssKey(SER_DISK); @@ -117,7 +116,7 @@ protected: if (!pdb) return false; if (fReadOnly) - assert(("Erase called on database in read-only mode", false)); + assert(!"Erase called on database in read-only mode"); // Key CDataStream ssKey(SER_DISK); @@ -256,6 +255,8 @@ public: { return Write(std::string("version"), nVersion); } + + bool static Rewrite(const std::string& strFile, const char* pszSkip = NULL); }; @@ -346,7 +347,9 @@ enum DBErrors { DB_LOAD_OK, DB_CORRUPT, - DB_TOO_NEW + DB_TOO_NEW, + DB_LOAD_FAIL, + DB_NEED_REWRITE }; class CWalletDB : public CDB @@ -398,6 +401,25 @@ public: return Write(std::make_pair(std::string("key"), vchPubKey), vchPrivKey, false); } + bool WriteCryptedKey(const std::vector& vchPubKey, const std::vector& vchCryptedSecret, bool fEraseUnencryptedKey = true) + { + nWalletDBUpdated++; + if (!Write(std::make_pair(std::string("ckey"), vchPubKey), vchCryptedSecret, false)) + return false; + if (fEraseUnencryptedKey) + { + Erase(std::make_pair(std::string("key"), vchPubKey)); + Erase(std::make_pair(std::string("wkey"), vchPubKey)); + } + return true; + } + + bool WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey) + { + nWalletDBUpdated++; + return Write(std::make_pair(std::string("mkey"), nID), kMasterKey, true); + } + bool WriteBestBlock(const CBlockLocator& locator) { nWalletDBUpdated++;