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-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 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 "chainparams.h" | #include "chainparams.h" | ||||
#include "config.h" | #include "config.h" | ||||
#include "hash.h" | #include "hash.h" | ||||
#include "init.h" | #include "init.h" | ||||
#include "pow.h" | #include "pow.h" | ||||
#include "ui_interface.h" | |||||
#include "random.h" | #include "random.h" | ||||
#include "ui_interface.h" | |||||
#include "uint256.h" | #include "uint256.h" | ||||
#include "util.h" | #include "util.h" | ||||
#include <boost/thread.hpp> | #include <boost/thread.hpp> | ||||
#include <cstdint> | #include <cstdint> | ||||
static const char DB_COIN = 'C'; | static const char DB_COIN = 'C'; | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | std::vector<uint256> CCoinsViewDB::GetHeadBlocks() const { | ||||
} | } | ||||
return vhashHeadBlocks; | return vhashHeadBlocks; | ||||
} | } | ||||
bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { | bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { | ||||
CDBBatch batch(db); | CDBBatch batch(db); | ||||
size_t count = 0; | size_t count = 0; | ||||
size_t changed = 0; | size_t changed = 0; | ||||
size_t batch_size = (size_t)GetArg("-dbbatchsize", nDefaultDbBatchSize); | size_t batch_size = | ||||
int crash_simulate = GetArg("-dbcrashratio", 0); | (size_t)gArgs.GetArg("-dbbatchsize", nDefaultDbBatchSize); | ||||
int crash_simulate = gArgs.GetArg("-dbcrashratio", 0); | |||||
assert(!hashBlock.IsNull()); | assert(!hashBlock.IsNull()); | ||||
uint256 old_tip = GetBestBlock(); | uint256 old_tip = GetBestBlock(); | ||||
if (old_tip.IsNull()) { | if (old_tip.IsNull()) { | ||||
// We may be in the middle of replaying. | // We may be in the middle of replaying. | ||||
std::vector<uint256> old_heads = GetHeadBlocks(); | std::vector<uint256> old_heads = GetHeadBlocks(); | ||||
if (old_heads.size() == 2) { | if (old_heads.size() == 2) { | ||||
assert(old_heads[0] == hashBlock); | assert(old_heads[0] == hashBlock); | ||||
▲ Show 20 Lines • Show All 360 Lines • Show Last 20 Lines |