Skip to content

Commit

Permalink
trivial: use constants for db keys
Browse files Browse the repository at this point in the history
Replace literal occurances of the key "prefixes" 'c' and 'b' in txdb.cpp
by the respective constants.
  • Loading branch information
domob1812 authored and str4d committed Apr 3, 2018
1 parent 26cdb83 commit c775869
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
only need read operations on it, use a const-cast to get around
that restriction. */
boost::scoped_ptr<CLevelDBIterator> pcursor(const_cast<CLevelDBWrapper*>(&db)->NewIterator());
pcursor->Seek('c');
pcursor->Seek(DB_COINS);

CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION);
stats.hashBlock = GetBestBlock();
Expand All @@ -173,7 +173,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
boost::this_thread::interruption_point();
std::pair<char, uint256> key;
CCoins coins;
if (pcursor->GetKey(key) && key.first == 'c') {
if (pcursor->GetKey(key) && key.first == DB_COINS) {
if (pcursor->GetValue(coins)) {
stats.nTransactions++;
for (unsigned int i=0; i<coins.vout.size(); i++) {
Expand Down Expand Up @@ -251,13 +251,13 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
{
boost::scoped_ptr<CLevelDBIterator> pcursor(NewIterator());

pcursor->Seek(make_pair('b', uint256()));
pcursor->Seek(make_pair(DB_BLOCK_INDEX, uint256()));

// Load mapBlockIndex
while (pcursor->Valid()) {
boost::this_thread::interruption_point();
std::pair<char, uint256> key;
if (pcursor->GetKey(key) && key.first == 'b') {
if (pcursor->GetKey(key) && key.first == DB_BLOCK_INDEX) {
CDiskBlockIndex diskindex;
if (pcursor->GetValue(diskindex)) {
// Construct block index object
Expand Down

0 comments on commit c775869

Please sign in to comment.