@@ -123,6 +123,19 @@ class CBlockTreeDB : public CDBWrapper
123123 bool LoadBlockIndexGuts (const Consensus::Params& consensusParams, std::function<CBlockIndex*(const uint256&)> insertBlockIndex);
124124};
125125
126+ class BaseIndexDB : public CDBWrapper
127+ {
128+ public:
129+ BaseIndexDB (const fs::path& path, size_t n_cache_size,
130+ bool f_memory = false , bool f_wipe = false , bool f_obfuscate = false );
131+
132+ // / Read block locator of the chain that the index is in sync with.
133+ bool ReadBestBlock (CBlockLocator& locator) const ;
134+
135+ // / Write block locator of the chain that the index is in sync with.
136+ bool WriteBestBlock (const CBlockLocator& locator);
137+ };
138+
126139/* *
127140 * Access to the txindex database (indexes/txindex/)
128141 *
@@ -132,7 +145,7 @@ class CBlockTreeDB : public CDBWrapper
132145 * and block index entries may not be flushed to disk until after this database
133146 * is updated.
134147 */
135- class TxIndexDB : public CDBWrapper
148+ class TxIndexDB : public BaseIndexDB
136149{
137150public:
138151 explicit TxIndexDB (size_t n_cache_size, bool f_memory = false , bool f_wipe = false );
@@ -144,12 +157,6 @@ class TxIndexDB : public CDBWrapper
144157 // / Write a batch of transaction positions to the DB.
145158 bool WriteTxs (const std::vector<std::pair<uint256, CDiskTxPos>>& v_pos);
146159
147- // / Read block locator of the chain that the txindex is in sync with.
148- bool ReadBestBlock (CBlockLocator& locator) const ;
149-
150- // / Write block locator of the chain that the txindex is in sync with.
151- bool WriteBestBlock (const CBlockLocator& locator);
152-
153160 // / Migrate txindex data from the block tree DB, where it may be for older nodes that have not
154161 // / been upgraded yet to the new database.
155162 bool MigrateData (CBlockTreeDB& block_tree_db, const CBlockLocator& best_locator);
0 commit comments