diff options
author | Jim Posen <jim.posen@gmail.com> | 2018-05-15 14:57:22 -0700 |
---|---|---|
committer | Jim Posen <jim.posen@gmail.com> | 2018-06-04 19:22:21 -0700 |
commit | e5af5fc6fb4658599b940d1d50853129b31b8766 (patch) | |
tree | 49a664e962fe76d77e22364750cf6ca3dd0d74db /src/txdb.h | |
parent | 9b0ec1a7f9ffae816fd5ca32ff7e7559640b6f6d (diff) |
db: Make reusable base class for index databases.
Diffstat (limited to 'src/txdb.h')
-rw-r--r-- | src/txdb.h | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/txdb.h b/src/txdb.h index 3c509373f4..f9d9e4246c 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -123,6 +123,19 @@ public: bool LoadBlockIndexGuts(const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex); }; +class BaseIndexDB : public CDBWrapper +{ +public: + BaseIndexDB(const fs::path& path, size_t n_cache_size, + bool f_memory = false, bool f_wipe = false, bool f_obfuscate = false); + + /// Read block locator of the chain that the index is in sync with. + bool ReadBestBlock(CBlockLocator& locator) const; + + /// Write block locator of the chain that the index is in sync with. + bool WriteBestBlock(const CBlockLocator& locator); +}; + /** * Access to the txindex database (indexes/txindex/) * @@ -132,7 +145,7 @@ public: * and block index entries may not be flushed to disk until after this database * is updated. */ -class TxIndexDB : public CDBWrapper +class TxIndexDB : public BaseIndexDB { public: explicit TxIndexDB(size_t n_cache_size, bool f_memory = false, bool f_wipe = false); @@ -144,12 +157,6 @@ public: /// Write a batch of transaction positions to the DB. bool WriteTxs(const std::vector<std::pair<uint256, CDiskTxPos>>& v_pos); - /// Read block locator of the chain that the txindex is in sync with. - bool ReadBestBlock(CBlockLocator& locator) const; - - /// Write block locator of the chain that the txindex is in sync with. - bool WriteBestBlock(const CBlockLocator& locator); - /// Migrate txindex data from the block tree DB, where it may be for older nodes that have not /// been upgraded yet to the new database. bool MigrateData(CBlockTreeDB& block_tree_db, const CBlockLocator& best_locator); |