Changeset View
Changeset View
Standalone View
Standalone View
src/txdb.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2018 The Bitcoin Core developers | // Copyright (c) 2009-2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <txdb.h> | #include <txdb.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <pow/pow.h> | #include <pow/pow.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <shutdown.h> | #include <shutdown.h> | ||||
#include <ui_interface.h> | #include <ui_interface.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#include <util/vector.h> | |||||
#include <boost/thread.hpp> // boost::this_thread::interruption_point() (mingw) | #include <boost/thread.hpp> // boost::this_thread::interruption_point() (mingw) | ||||
#include <cstdint> | #include <cstdint> | ||||
static const char DB_COIN = 'C'; | static const char DB_COIN = 'C'; | ||||
static const char DB_COINS = 'c'; | static const char DB_COINS = 'c'; | ||||
static const char DB_BLOCK_FILES = 'f'; | static const char DB_BLOCK_FILES = 'f'; | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | if (old_tip.IsNull()) { | ||||
} | } | ||||
} | } | ||||
// In the first batch, mark the database as being in the middle of a | // In the first batch, mark the database as being in the middle of a | ||||
// transition from old_tip to hashBlock. | // transition from old_tip to hashBlock. | ||||
// A vector is used for future extensibility, as we may want to support | // A vector is used for future extensibility, as we may want to support | ||||
// interrupting after partial writes from multiple independent reorgs. | // interrupting after partial writes from multiple independent reorgs. | ||||
batch.Erase(DB_BEST_BLOCK); | batch.Erase(DB_BEST_BLOCK); | ||||
batch.Write(DB_HEAD_BLOCKS, std::vector<BlockHash>{hashBlock, old_tip}); | batch.Write(DB_HEAD_BLOCKS, Vector(hashBlock, old_tip)); | ||||
for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) { | for (CCoinsMap::iterator it = mapCoins.begin(); it != mapCoins.end();) { | ||||
if (it->second.flags & CCoinsCacheEntry::DIRTY) { | if (it->second.flags & CCoinsCacheEntry::DIRTY) { | ||||
CoinEntry entry(&it->first); | CoinEntry entry(&it->first); | ||||
if (it->second.coin.IsSpent()) { | if (it->second.coin.IsSpent()) { | ||||
batch.Erase(entry); | batch.Erase(entry); | ||||
} else { | } else { | ||||
batch.Write(entry, it->second.coin); | batch.Write(entry, it->second.coin); | ||||
▲ Show 20 Lines • Show All 333 Lines • Show Last 20 Lines |