Changeset View
Changeset View
Standalone View
Standalone View
src/txdb.cpp
Show All 10 Lines | |||||
#include <pow/pow.h> | #include <pow/pow.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <shutdown.h> | #include <shutdown.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#include <util/vector.h> | #include <util/vector.h> | ||||
#include <version.h> | #include <version.h> | ||||
#include <boost/thread.hpp> // boost::this_thread::interruption_point() (mingw) | |||||
#include <cstdint> | #include <cstdint> | ||||
#include <memory> | #include <memory> | ||||
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'; | ||||
static const char DB_BLOCK_INDEX = 'b'; | static const char DB_BLOCK_INDEX = 'b'; | ||||
▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Lines | if (version != CLIENT_VERSION) { | ||||
return error("%s: Invalid block index database version: %s", __func__, | return error("%s: Invalid block index database version: %s", __func__, | ||||
version); | version); | ||||
} | } | ||||
pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256())); | pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256())); | ||||
// Load m_block_index | // Load m_block_index | ||||
while (pcursor->Valid()) { | while (pcursor->Valid()) { | ||||
boost::this_thread::interruption_point(); | |||||
if (ShutdownRequested()) { | if (ShutdownRequested()) { | ||||
return false; | return false; | ||||
} | } | ||||
std::pair<char, uint256> key; | std::pair<char, uint256> key; | ||||
if (!pcursor->GetKey(key) || key.first != DB_BLOCK_INDEX) { | if (!pcursor->GetKey(key) || key.first != DB_BLOCK_INDEX) { | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | bool CCoinsViewDB::Upgrade() { | ||||
int64_t count = 0; | int64_t count = 0; | ||||
LogPrintf("Upgrading utxo-set database...\n"); | LogPrintf("Upgrading utxo-set database...\n"); | ||||
size_t batch_size = 1 << 24; | size_t batch_size = 1 << 24; | ||||
CDBBatch batch(*m_db); | CDBBatch batch(*m_db); | ||||
int reportDone = -1; | int reportDone = -1; | ||||
std::pair<uint8_t, uint256> key; | std::pair<uint8_t, uint256> key; | ||||
std::pair<uint8_t, uint256> prev_key = {DB_COINS, uint256()}; | std::pair<uint8_t, uint256> prev_key = {DB_COINS, uint256()}; | ||||
while (pcursor->Valid()) { | while (pcursor->Valid()) { | ||||
boost::this_thread::interruption_point(); | |||||
if (ShutdownRequested()) { | if (ShutdownRequested()) { | ||||
break; | break; | ||||
} | } | ||||
if (!pcursor->GetKey(key) || key.first != DB_COINS) { | if (!pcursor->GetKey(key) || key.first != DB_COINS) { | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 152 Lines • Show Last 20 Lines |