X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fdb.h;h=38daad3e919c0fbbe52b761435de1a0af86c81e3;hb=d11488abd05cb39a9f481e7c4c35f780197a3d28;hp=15bfb29c8e934ceed37f26659960a9ca9f278f88;hpb=76ef6d89b98b57d2ee5c6db993cd1cc375dd3726;p=novacoin.git diff --git a/src/db.h b/src/db.h index 15bfb29..38daad3 100644 --- a/src/db.h +++ b/src/db.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers +// Copyright (c) 2009-2012 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 @@ -13,17 +13,18 @@ #include -class CTxIndex; +class CAccount; +class CAccountingEntry; +class CAddress; +class CAddrMan; +class CBlockLocator; class CDiskBlockIndex; class CDiskTxPos; +class CMasterKey; class COutPoint; -class CAddress; -class CWalletTx; +class CTxIndex; class CWallet; -class CAccount; -class CAccountingEntry; -class CBlockLocator; - +class CWalletTx; extern unsigned int nWalletDBUpdated; extern DbEnv dbenv; @@ -33,7 +34,7 @@ void ThreadFlushWalletDB(void* parg); bool BackupWallet(const CWallet& wallet, const std::string& strDest); - +/** RAII class that provides access to a Berkeley database */ class CDB { protected: @@ -265,7 +266,7 @@ public: - +/** Access to the transaction database (blkindex.dat) */ class CTxDB : public CDB { public: @@ -296,7 +297,7 @@ public: - +/** Access to the (IP) address database (addr.dat) */ class CAddrDB : public CDB { public: @@ -305,15 +306,14 @@ private: CAddrDB(const CAddrDB&); void operator=(const CAddrDB&); public: - bool WriteAddress(const CAddress& addr); - bool EraseAddress(const CAddress& addr); + bool WriteAddrman(const CAddrMan& addr); bool LoadAddresses(); }; bool LoadAddresses(); - +/** A key pool entry */ class CKeyPool { public: @@ -342,7 +342,7 @@ public: - +/** Error statuses for the wallet database */ enum DBErrors { DB_LOAD_OK, @@ -352,6 +352,7 @@ enum DBErrors DB_NEED_REWRITE }; +/** Access to the wallet database (wallet.dat) */ class CWalletDB : public CDB { public: @@ -420,6 +421,19 @@ public: return Write(std::make_pair(std::string("mkey"), nID), kMasterKey, true); } + // Support for BIP 0013 : see https://en.bitcoin.it/wiki/BIP_0013 + bool ReadCScript(const uint160 &hash, CScript& redeemScript) + { + redeemScript.clear(); + return Read(std::make_pair(std::string("cscript"), hash), redeemScript); + } + + bool WriteCScript(const uint160& hash, const CScript& redeemScript) + { + nWalletDBUpdated++; + return Write(std::make_pair(std::string("cscript"), hash), redeemScript, false); + } + bool WriteBestBlock(const CBlockLocator& locator) { nWalletDBUpdated++; @@ -460,18 +474,29 @@ public: return Erase(std::make_pair(std::string("pool"), nPool)); } + // Settings are no longer stored in wallet.dat; these are + // used only for backwards compatibility: template bool ReadSetting(const std::string& strKey, T& value) { return Read(std::make_pair(std::string("setting"), strKey), value); } - template bool WriteSetting(const std::string& strKey, const T& value) { nWalletDBUpdated++; return Write(std::make_pair(std::string("setting"), strKey), value); } + bool EraseSetting(const std::string& strKey) + { + nWalletDBUpdated++; + return Erase(std::make_pair(std::string("setting"), strKey)); + } + + bool WriteMinVersion(int nVersion) + { + return Write(std::string("minversion"), nVersion); + } bool ReadAccount(const std::string& strAccount, CAccount& account); bool WriteAccount(const std::string& strAccount, const CAccount& account);