Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 5,233 Lines • ▼ Show 20 Lines | bool CChainState::LoadGenesisBlock(const CChainParams &chainparams) { | ||||
return true; | return true; | ||||
} | } | ||||
bool LoadGenesisBlock(const CChainParams &chainparams) { | bool LoadGenesisBlock(const CChainParams &chainparams) { | ||||
return ::ChainstateActive().LoadGenesisBlock(chainparams); | return ::ChainstateActive().LoadGenesisBlock(chainparams); | ||||
} | } | ||||
bool LoadExternalBlockFile(const Config &config, FILE *fileIn, | void LoadExternalBlockFile(const Config &config, FILE *fileIn, | ||||
FlatFilePos *dbp) { | FlatFilePos *dbp) { | ||||
// Map of disk positions for blocks with unknown parent (only used for | // Map of disk positions for blocks with unknown parent (only used for | ||||
// reindex) | // reindex) | ||||
static std::multimap<uint256, FlatFilePos> mapBlocksUnknownParent; | static std::multimap<uint256, FlatFilePos> mapBlocksUnknownParent; | ||||
int64_t nStart = GetTimeMillis(); | int64_t nStart = GetTimeMillis(); | ||||
const CChainParams &chainparams = config.GetChainParams(); | const CChainParams &chainparams = config.GetChainParams(); | ||||
int nLoaded = 0; | int nLoaded = 0; | ||||
try { | try { | ||||
// This takes over fileIn and calls fclose() on it in the CBufferedFile | // This takes over fileIn and calls fclose() on it in the CBufferedFile | ||||
// destructor. Make sure we have at least 2*MAX_TX_SIZE space in there | // destructor. Make sure we have at least 2*MAX_TX_SIZE space in there | ||||
// so any transaction can fit in the buffer. | // so any transaction can fit in the buffer. | ||||
CBufferedFile blkdat(fileIn, 2 * MAX_TX_SIZE, MAX_TX_SIZE + 8, SER_DISK, | CBufferedFile blkdat(fileIn, 2 * MAX_TX_SIZE, MAX_TX_SIZE + 8, SER_DISK, | ||||
CLIENT_VERSION); | CLIENT_VERSION); | ||||
uint64_t nRewind = blkdat.GetPos(); | uint64_t nRewind = blkdat.GetPos(); | ||||
while (!blkdat.eof()) { | while (!blkdat.eof()) { | ||||
boost::this_thread::interruption_point(); | if (ShutdownRequested()) { | ||||
return; | |||||
} | |||||
blkdat.SetPos(nRewind); | blkdat.SetPos(nRewind); | ||||
// Start one byte further next time, in case of failure. | // Start one byte further next time, in case of failure. | ||||
nRewind++; | nRewind++; | ||||
// Remove former limit. | // Remove former limit. | ||||
blkdat.SetLimit(); | blkdat.SetLimit(); | ||||
unsigned int nSize = 0; | unsigned int nSize = 0; | ||||
try { | try { | ||||
▲ Show 20 Lines • Show All 120 Lines • ▼ Show 20 Lines | try { | ||||
LogPrintf("%s: Deserialize or I/O error - %s\n", __func__, | LogPrintf("%s: Deserialize or I/O error - %s\n", __func__, | ||||
e.what()); | e.what()); | ||||
} | } | ||||
} | } | ||||
} catch (const std::runtime_error &e) { | } catch (const std::runtime_error &e) { | ||||
AbortNode(std::string("System error: ") + e.what()); | AbortNode(std::string("System error: ") + e.what()); | ||||
} | } | ||||
if (nLoaded > 0) { | |||||
LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, | LogPrintf("Loaded %i blocks from external file in %dms\n", nLoaded, | ||||
GetTimeMillis() - nStart); | GetTimeMillis() - nStart); | ||||
} | } | ||||
return nLoaded > 0; | |||||
} | |||||
void CChainState::CheckBlockIndex(const Consensus::Params &consensusParams) { | void CChainState::CheckBlockIndex(const Consensus::Params &consensusParams) { | ||||
if (!fCheckBlockIndex) { | if (!fCheckBlockIndex) { | ||||
return; | return; | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// During a reindex, we read the genesis block and call CheckBlockIndex | // During a reindex, we read the genesis block and call CheckBlockIndex | ||||
▲ Show 20 Lines • Show All 656 Lines • Show Last 20 Lines |