Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 2,984 Lines • ▼ Show 20 Lines | |||||
else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex) { | else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex) { | ||||
// Ignore blocks received while importing. | // Ignore blocks received while importing. | ||||
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); | std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); | ||||
vRecv >> *pblock; | vRecv >> *pblock; | ||||
LogPrint(BCLog::NET, "received block %s peer=%d\n", | LogPrint(BCLog::NET, "received block %s peer=%d\n", | ||||
pblock->GetHash().ToString(), pfrom->GetId()); | pblock->GetHash().ToString(), pfrom->GetId()); | ||||
// Process all blocks from whitelisted peers, even if not requested, | bool forceProcessing = false; | ||||
// unless we're still syncing with the network. Such an unrequested | |||||
// block may still be processed, subject to the conditions in | |||||
// AcceptBlock(). | |||||
bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload(); | |||||
const uint256 hash(pblock->GetHash()); | const uint256 hash(pblock->GetHash()); | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// Also always process if we requested the block explicitly, as we | // Also always process if we requested the block explicitly, as we | ||||
// may need it even though it is not a candidate for a new best tip. | // may need it even though it is not a candidate for a new best tip. | ||||
forceProcessing |= MarkBlockAsReceived(hash); | forceProcessing |= MarkBlockAsReceived(hash); | ||||
// mapBlockSource is only used for sending reject messages and DoS | // mapBlockSource is only used for sending reject messages and DoS | ||||
// scores, so the race between here and cs_main in ProcessNewBlock | // scores, so the race between here and cs_main in ProcessNewBlock | ||||
▲ Show 20 Lines • Show All 1,258 Lines • Show Last 20 Lines |