You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

txdb.h 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (c) 2009-2010 Satoshi Nakamoto
  2. // Copyright (c) 2009-2012 The Bitcoin developers
  3. // Distributed under the MIT/X11 software license, see the accompanying
  4. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  5. #ifndef BITCOIN_TXDB_LEVELDB_H
  6. #define BITCOIN_TXDB_LEVELDB_H
  7. #include "main.h"
  8. #include "leveldb.h"
  9. /** CCoinsView backed by the LevelDB coin database (chainstate/) */
  10. class CCoinsViewDB : public CCoinsView
  11. {
  12. protected:
  13. CLevelDB db;
  14. public:
  15. CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
  16. bool GetCoins(uint256 txid, CCoins &coins);
  17. bool SetCoins(uint256 txid, const CCoins &coins);
  18. bool HaveCoins(uint256 txid);
  19. CBlockIndex *GetBestBlock();
  20. bool SetBestBlock(CBlockIndex *pindex);
  21. bool BatchWrite(const std::map<uint256, CCoins> &mapCoins, CBlockIndex *pindex);
  22. bool GetStats(CCoinsStats &stats);
  23. };
  24. /** Access to the block database (blocks/index/) */
  25. class CBlockTreeDB : public CLevelDB
  26. {
  27. public:
  28. CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
  29. private:
  30. CBlockTreeDB(const CBlockTreeDB&);
  31. void operator=(const CBlockTreeDB&);
  32. public:
  33. bool WriteBlockIndex(const CDiskBlockIndex& blockindex);
  34. bool ReadBestInvalidWork(CBigNum& bnBestInvalidWork);
  35. bool WriteBestInvalidWork(const CBigNum& bnBestInvalidWork);
  36. bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo);
  37. bool WriteBlockFileInfo(int nFile, const CBlockFileInfo &fileinfo);
  38. bool ReadLastBlockFile(int &nFile);
  39. bool WriteLastBlockFile(int nFile);
  40. bool WriteReindexing(bool fReindex);
  41. bool ReadReindexing(bool &fReindex);
  42. bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
  43. bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
  44. bool WriteFlag(const std::string &name, bool fValue);
  45. bool ReadFlag(const std::string &name, bool &fValue);
  46. bool LoadBlockIndexGuts();
  47. };
  48. #endif // BITCOIN_TXDB_LEVELDB_H