Changeset View
Changeset View
Standalone View
Standalone View
src/txdb.cpp
Show First 20 Lines • Show All 438 Lines • ▼ Show 20 Lines | bool CCoinsViewDB::Upgrade() { | ||||
db.WriteBatch(batch); | db.WriteBatch(batch); | ||||
db.CompactRange({DB_COINS, uint256()}, key); | db.CompactRange({DB_COINS, uint256()}, key); | ||||
uiInterface.ShowProgress("", 100, false); | uiInterface.ShowProgress("", 100, false); | ||||
LogPrintf("[%s].\n", ShutdownRequested() ? "CANCELLED" : "DONE"); | LogPrintf("[%s].\n", ShutdownRequested() ? "CANCELLED" : "DONE"); | ||||
return !ShutdownRequested(); | 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) | TxIndexDB::TxIndexDB(size_t n_cache_size, bool f_memory, bool f_wipe) | ||||
: CDBWrapper(GetDataDir() / "indexes" / "txindex", n_cache_size, f_memory, | : BaseIndexDB(GetDataDir() / "indexes" / "txindex", n_cache_size, f_memory, | ||||
f_wipe) {} | f_wipe) {} | ||||
bool TxIndexDB::ReadTxPos(const uint256 &txid, CDiskTxPos &pos) const { | bool TxIndexDB::ReadTxPos(const uint256 &txid, CDiskTxPos &pos) const { | ||||
return Read(std::make_pair(DB_TXINDEX, txid), pos); | return Read(std::make_pair(DB_TXINDEX, txid), pos); | ||||
} | } | ||||
bool TxIndexDB::WriteTxs( | bool TxIndexDB::WriteTxs( | ||||
const std::vector<std::pair<uint256, CDiskTxPos>> &v_pos) { | const std::vector<std::pair<uint256, CDiskTxPos>> &v_pos) { | ||||
CDBBatch batch(*this); | CDBBatch batch(*this); | ||||
for (const auto &tuple : v_pos) { | for (const auto &tuple : v_pos) { | ||||
batch.Write(std::make_pair(DB_TXINDEX, tuple.first), tuple.second); | batch.Write(std::make_pair(DB_TXINDEX, tuple.first), tuple.second); | ||||
} | } | ||||
return WriteBatch(batch); | return WriteBatch(batch); | ||||
} | } | ||||
bool TxIndexDB::ReadBestBlock(CBlockLocator &locator) const { | bool BaseIndexDB::ReadBestBlock(CBlockLocator &locator) const { | ||||
bool success = Read(DB_BEST_BLOCK, locator); | bool success = Read(DB_BEST_BLOCK, locator); | ||||
if (!success) { | if (!success) { | ||||
locator.SetNull(); | locator.SetNull(); | ||||
} | } | ||||
return success; | return success; | ||||
} | } | ||||
bool TxIndexDB::WriteBestBlock(const CBlockLocator &locator) { | bool BaseIndexDB::WriteBestBlock(const CBlockLocator &locator) { | ||||
return Write(DB_BEST_BLOCK, locator); | return Write(DB_BEST_BLOCK, locator); | ||||
} | } | ||||
/* | /* | ||||
* Safely persist a transfer of data from the old txindex database to the new | * Safely persist a transfer of data from the old txindex database to the new | ||||
* one, and compact the range of keys updated. This is used internally by | * one, and compact the range of keys updated. This is used internally by | ||||
* MigrateData. | * MigrateData. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |