Changeset View
Changeset View
Standalone View
Standalone View
src/index/txindex.cpp
// Copyright (c) 2017-2018 The Bitcoin Core developers | // Copyright (c) 2017-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 <index/txindex.h> | #include <index/txindex.h> | ||||
#include <blockdb.h> | #include <blockdb.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <node/ui_interface.h> | #include <node/ui_interface.h> | ||||
#include <shutdown.h> | #include <shutdown.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <util/translation.h> | #include <util/translation.h> | ||||
#include <validation.h> | #include <validation.h> | ||||
#include <boost/thread.hpp> | |||||
constexpr char DB_BEST_BLOCK = 'B'; | constexpr char DB_BEST_BLOCK = 'B'; | ||||
constexpr char DB_TXINDEX = 't'; | constexpr char DB_TXINDEX = 't'; | ||||
constexpr char DB_TXINDEX_BLOCK = 'T'; | constexpr char DB_TXINDEX_BLOCK = 'T'; | ||||
std::unique_ptr<TxIndex> g_txindex; | std::unique_ptr<TxIndex> g_txindex; | ||||
struct CDiskTxPos : public FlatFilePos { | struct CDiskTxPos : public FlatFilePos { | ||||
unsigned int nTxOffset; // after header | unsigned int nTxOffset; // after header | ||||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | bool TxIndex::DB::MigrateData(CBlockTreeDB &block_tree_db, | ||||
std::pair<uint8_t, TxId> key; | std::pair<uint8_t, TxId> key; | ||||
std::pair<uint8_t, TxId> begin_key{DB_TXINDEX, TxId()}; | std::pair<uint8_t, TxId> begin_key{DB_TXINDEX, TxId()}; | ||||
std::pair<uint8_t, TxId> prev_key = begin_key; | std::pair<uint8_t, TxId> prev_key = begin_key; | ||||
bool interrupted = false; | bool interrupted = false; | ||||
std::unique_ptr<CDBIterator> cursor(block_tree_db.NewIterator()); | std::unique_ptr<CDBIterator> cursor(block_tree_db.NewIterator()); | ||||
for (cursor->Seek(begin_key); cursor->Valid(); cursor->Next()) { | for (cursor->Seek(begin_key); cursor->Valid(); cursor->Next()) { | ||||
boost::this_thread::interruption_point(); | |||||
if (ShutdownRequested()) { | if (ShutdownRequested()) { | ||||
interrupted = true; | interrupted = true; | ||||
break; | break; | ||||
} | } | ||||
if (!cursor->GetKey(key)) { | if (!cursor->GetKey(key)) { | ||||
return error("%s: cannot get key from valid cursor", __func__); | return error("%s: cannot get key from valid cursor", __func__); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |