mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-16 03:23:08 +02:00
db: Make reusable base class for index databases.
This commit is contained in:
10
src/txdb.cpp
10
src/txdb.cpp
@ -415,8 +415,12 @@ bool CCoinsViewDB::Upgrade() {
|
||||
return !ShutdownRequested();
|
||||
}
|
||||
|
||||
BaseIndexDB::BaseIndexDB(const fs::path& path, size_t n_cache_size, bool f_memory, bool f_wipe, bool f_obfuscate) :
|
||||
CDBWrapper(path, n_cache_size, f_memory, f_wipe, f_obfuscate)
|
||||
{}
|
||||
|
||||
TxIndexDB::TxIndexDB(size_t n_cache_size, bool f_memory, bool f_wipe) :
|
||||
CDBWrapper(GetDataDir() / "indexes" / "txindex", n_cache_size, f_memory, f_wipe)
|
||||
BaseIndexDB(GetDataDir() / "indexes" / "txindex", n_cache_size, f_memory, f_wipe)
|
||||
{}
|
||||
|
||||
bool TxIndexDB::ReadTxPos(const uint256 &txid, CDiskTxPos& pos) const
|
||||
@ -433,7 +437,7 @@ bool TxIndexDB::WriteTxs(const std::vector<std::pair<uint256, CDiskTxPos>>& v_po
|
||||
return WriteBatch(batch);
|
||||
}
|
||||
|
||||
bool TxIndexDB::ReadBestBlock(CBlockLocator& locator) const
|
||||
bool BaseIndexDB::ReadBestBlock(CBlockLocator& locator) const
|
||||
{
|
||||
bool success = Read(DB_BEST_BLOCK, locator);
|
||||
if (!success) {
|
||||
@ -442,7 +446,7 @@ bool TxIndexDB::ReadBestBlock(CBlockLocator& locator) const
|
||||
return success;
|
||||
}
|
||||
|
||||
bool TxIndexDB::WriteBestBlock(const CBlockLocator& locator)
|
||||
bool BaseIndexDB::WriteBestBlock(const CBlockLocator& locator)
|
||||
{
|
||||
return Write(DB_BEST_BLOCK, locator);
|
||||
}
|
||||
|
Reference in New Issue
Block a user