Changeset View
Changeset View
Standalone View
Standalone View
src/txdb.cpp
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool CCoinsViewDB::HaveCoin(const COutPoint &outpoint) const { | bool CCoinsViewDB::HaveCoin(const COutPoint &outpoint) const { | ||||
return db.Exists(CoinEntry(&outpoint)); | return db.Exists(CoinEntry(&outpoint)); | ||||
} | } | ||||
uint256 CCoinsViewDB::GetBestBlock() const { | uint256 CCoinsViewDB::GetBestBlock() const { | ||||
uint256 hashBestChain; | uint256 hashBestChain; | ||||
if (!db.Read(DB_BEST_BLOCK, hashBestChain)) return uint256(); | if (!db.Read(DB_BEST_BLOCK, hashBestChain)) { | ||||
return uint256(); | |||||
} | |||||
return hashBestChain; | return hashBestChain; | ||||
} | } | ||||
std::vector<uint256> CCoinsViewDB::GetHeadBlocks() const { | std::vector<uint256> CCoinsViewDB::GetHeadBlocks() const { | ||||
std::vector<uint256> vhashHeadBlocks; | std::vector<uint256> vhashHeadBlocks; | ||||
if (!db.Read(DB_HEAD_BLOCKS, vhashHeadBlocks)) { | if (!db.Read(DB_HEAD_BLOCKS, vhashHeadBlocks)) { | ||||
return std::vector<uint256>(); | return std::vector<uint256>(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | : CDBWrapper(gArgs.IsArgSet("-blocksdir") | ||||
: GetBlocksDir() / "index", | : GetBlocksDir() / "index", | ||||
nCacheSize, fMemory, fWipe) {} | nCacheSize, fMemory, fWipe) {} | ||||
bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) { | bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) { | ||||
return Read(std::make_pair(DB_BLOCK_FILES, nFile), info); | return Read(std::make_pair(DB_BLOCK_FILES, nFile), info); | ||||
} | } | ||||
bool CBlockTreeDB::WriteReindexing(bool fReindexing) { | bool CBlockTreeDB::WriteReindexing(bool fReindexing) { | ||||
if (fReindexing) | if (fReindexing) { | ||||
return Write(DB_REINDEX_FLAG, '1'); | return Write(DB_REINDEX_FLAG, '1'); | ||||
else | } else { | ||||
return Erase(DB_REINDEX_FLAG); | return Erase(DB_REINDEX_FLAG); | ||||
} | } | ||||
} | |||||
void CBlockTreeDB::ReadReindexing(bool &fReindexing) { | void CBlockTreeDB::ReadReindexing(bool &fReindexing) { | ||||
fReindexing = Exists(DB_REINDEX_FLAG); | fReindexing = Exists(DB_REINDEX_FLAG); | ||||
} | } | ||||
bool CBlockTreeDB::ReadLastBlockFile(int &nFile) { | bool CBlockTreeDB::ReadLastBlockFile(int &nFile) { | ||||
return Read(DB_LAST_BLOCK, nFile); | return Read(DB_LAST_BLOCK, nFile); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool CBlockTreeDB::WriteFlag(const std::string &name, bool fValue) { | bool CBlockTreeDB::WriteFlag(const std::string &name, bool fValue) { | ||||
return Write(std::make_pair(DB_FLAG, name), fValue ? '1' : '0'); | return Write(std::make_pair(DB_FLAG, name), fValue ? '1' : '0'); | ||||
} | } | ||||
bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) { | bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) { | ||||
char ch; | char ch; | ||||
if (!Read(std::make_pair(DB_FLAG, name), ch)) return false; | if (!Read(std::make_pair(DB_FLAG, name), ch)) { | ||||
return false; | |||||
} | |||||
fValue = ch == '1'; | fValue = ch == '1'; | ||||
return true; | return true; | ||||
} | } | ||||
bool CBlockTreeDB::LoadBlockIndexGuts( | bool CBlockTreeDB::LoadBlockIndexGuts( | ||||
const Consensus::Params ¶ms, | const Consensus::Params ¶ms, | ||||
std::function<CBlockIndex *(const uint256 &)> insertBlockIndex) { | std::function<CBlockIndex *(const uint256 &)> insertBlockIndex) { | ||||
▲ Show 20 Lines • Show All 176 Lines • Show Last 20 Lines |