Changeset View
Changeset View
Standalone View
Standalone View
src/txdb.cpp
Show First 20 Lines • Show All 246 Lines • ▼ Show 20 Lines | for (std::vector<const CBlockIndex *>::const_iterator it = | ||||
blockinfo.begin(); | blockinfo.begin(); | ||||
it != blockinfo.end(); it++) { | it != blockinfo.end(); it++) { | ||||
batch.Write(std::make_pair(DB_BLOCK_INDEX, (*it)->GetBlockHash()), | batch.Write(std::make_pair(DB_BLOCK_INDEX, (*it)->GetBlockHash()), | ||||
CDiskBlockIndex(*it)); | CDiskBlockIndex(*it)); | ||||
} | } | ||||
return WriteBatch(batch, true); | return WriteBatch(batch, true); | ||||
} | } | ||||
bool CBlockTreeDB::ReadTxIndex(const uint256 &txid, CDiskTxPos &pos) { | |||||
return Read(std::make_pair(DB_TXINDEX, txid), pos); | |||||
} | |||||
bool CBlockTreeDB::WriteTxIndex( | |||||
const std::vector<std::pair<uint256, CDiskTxPos>> &vect) { | |||||
CDBBatch batch(*this); | |||||
for (std::vector<std::pair<uint256, CDiskTxPos>>::const_iterator it = | |||||
vect.begin(); | |||||
it != vect.end(); it++) | |||||
batch.Write(std::make_pair(DB_TXINDEX, it->first), it->second); | |||||
return WriteBatch(batch); | |||||
} | |||||
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'; | ||||
▲ Show 20 Lines • Show All 355 Lines • Show Last 20 Lines |