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 "hash.h" | #include "hash.h" | ||||
#include "pow.h" | #include "pow.h" | ||||
#include "uint256.h" | #include "uint256.h" | ||||
#include <cstdint> | #include <cstdint> | ||||
#include <boost/thread.hpp> | #include <boost/thread.hpp> | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) { | ||||
char ch; | char ch; | ||||
if (!Read(std::make_pair(DB_FLAG, name), ch)) return false; | if (!Read(std::make_pair(DB_FLAG, name), ch)) return false; | ||||
fValue = ch == '1'; | fValue = ch == '1'; | ||||
return true; | return true; | ||||
} | } | ||||
bool CBlockTreeDB::LoadBlockIndexGuts( | bool CBlockTreeDB::LoadBlockIndexGuts( | ||||
std::function<CBlockIndex *(const uint256 &)> insertBlockIndex) { | std::function<CBlockIndex *(const uint256 &)> insertBlockIndex) { | ||||
const Config &config = GetConfig(); | |||||
std::unique_ptr<CDBIterator> pcursor(NewIterator()); | std::unique_ptr<CDBIterator> pcursor(NewIterator()); | ||||
pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256())); | pcursor->Seek(std::make_pair(DB_BLOCK_INDEX, uint256())); | ||||
// Load mapBlockIndex | // Load mapBlockIndex | ||||
while (pcursor->Valid()) { | while (pcursor->Valid()) { | ||||
boost::this_thread::interruption_point(); | boost::this_thread::interruption_point(); | ||||
std::pair<char, uint256> key; | std::pair<char, uint256> key; | ||||
Show All 17 Lines | while (pcursor->Valid()) { | ||||
pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot; | pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot; | ||||
pindexNew->nTime = diskindex.nTime; | pindexNew->nTime = diskindex.nTime; | ||||
pindexNew->nBits = diskindex.nBits; | pindexNew->nBits = diskindex.nBits; | ||||
pindexNew->nNonce = diskindex.nNonce; | pindexNew->nNonce = diskindex.nNonce; | ||||
pindexNew->nStatus = diskindex.nStatus; | pindexNew->nStatus = diskindex.nStatus; | ||||
pindexNew->nTx = diskindex.nTx; | pindexNew->nTx = diskindex.nTx; | ||||
if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, | if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, | ||||
Params().GetConsensus())) | config)) { | ||||
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", | return error("LoadBlockIndex(): CheckProofOfWork failed: %s", | ||||
pindexNew->ToString()); | pindexNew->ToString()); | ||||
} | |||||
pcursor->Next(); | pcursor->Next(); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
namespace { | namespace { | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |