|
|
@ -1895,7 +1895,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
BlockTransactions resp; |
|
|
|
BlockTransactions resp; |
|
|
|
vRecv >> resp; |
|
|
|
vRecv >> resp; |
|
|
|
|
|
|
|
|
|
|
|
CBlock block; |
|
|
|
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); |
|
|
|
bool fBlockRead = false; |
|
|
|
bool fBlockRead = false; |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_main); |
|
|
|
LOCK(cs_main); |
|
|
@ -1908,7 +1908,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock; |
|
|
|
PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock; |
|
|
|
ReadStatus status = partialBlock.FillBlock(block, resp.txn); |
|
|
|
ReadStatus status = partialBlock.FillBlock(*pblock, resp.txn); |
|
|
|
if (status == READ_STATUS_INVALID) { |
|
|
|
if (status == READ_STATUS_INVALID) { |
|
|
|
MarkBlockAsReceived(resp.blockhash); // Reset in-flight state in case of whitelist
|
|
|
|
MarkBlockAsReceived(resp.blockhash); // Reset in-flight state in case of whitelist
|
|
|
|
Misbehaving(pfrom->GetId(), 100); |
|
|
|
Misbehaving(pfrom->GetId(), 100); |
|
|
@ -1951,7 +1951,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
bool fNewBlock = false; |
|
|
|
bool fNewBlock = false; |
|
|
|
// Since we requested this block (it was in mapBlocksInFlight), force it to be processed,
|
|
|
|
// Since we requested this block (it was in mapBlocksInFlight), force it to be processed,
|
|
|
|
// even if it would not be a candidate for new tip (missing previous block, chain not long enough, etc)
|
|
|
|
// even if it would not be a candidate for new tip (missing previous block, chain not long enough, etc)
|
|
|
|
ProcessNewBlock(chainparams, &block, true, NULL, &fNewBlock); |
|
|
|
ProcessNewBlock(chainparams, pblock, true, NULL, &fNewBlock); |
|
|
|
if (fNewBlock) |
|
|
|
if (fNewBlock) |
|
|
|
pfrom->nLastBlockTime = GetTime(); |
|
|
|
pfrom->nLastBlockTime = GetTime(); |
|
|
|
} |
|
|
|
} |
|
|
@ -2112,17 +2112,17 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
|
|
|
|
|
|
|
|
else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex) // Ignore blocks received while importing
|
|
|
|
else if (strCommand == NetMsgType::BLOCK && !fImporting && !fReindex) // Ignore blocks received while importing
|
|
|
|
{ |
|
|
|
{ |
|
|
|
CBlock block; |
|
|
|
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); |
|
|
|
vRecv >> block; |
|
|
|
vRecv >> *pblock; |
|
|
|
|
|
|
|
|
|
|
|
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id); |
|
|
|
LogPrint("net", "received block %s peer=%d\n", pblock->GetHash().ToString(), pfrom->id); |
|
|
|
|
|
|
|
|
|
|
|
// Process all blocks from whitelisted peers, even if not requested,
|
|
|
|
// Process all blocks from whitelisted peers, even if not requested,
|
|
|
|
// unless we're still syncing with the network.
|
|
|
|
// unless we're still syncing with the network.
|
|
|
|
// Such an unrequested block may still be processed, subject to the
|
|
|
|
// Such an unrequested block may still be processed, subject to the
|
|
|
|
// conditions in AcceptBlock().
|
|
|
|
// conditions in AcceptBlock().
|
|
|
|
bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload(); |
|
|
|
bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload(); |
|
|
|
const uint256 hash(block.GetHash()); |
|
|
|
const uint256 hash(pblock->GetHash()); |
|
|
|
{ |
|
|
|
{ |
|
|
|
LOCK(cs_main); |
|
|
|
LOCK(cs_main); |
|
|
|
// Also always process if we requested the block explicitly, as we may
|
|
|
|
// Also always process if we requested the block explicitly, as we may
|
|
|
@ -2133,7 +2133,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, |
|
|
|
mapBlockSource.emplace(hash, std::make_pair(pfrom->GetId(), true)); |
|
|
|
mapBlockSource.emplace(hash, std::make_pair(pfrom->GetId(), true)); |
|
|
|
} |
|
|
|
} |
|
|
|
bool fNewBlock = false; |
|
|
|
bool fNewBlock = false; |
|
|
|
ProcessNewBlock(chainparams, &block, forceProcessing, NULL, &fNewBlock); |
|
|
|
ProcessNewBlock(chainparams, pblock, forceProcessing, NULL, &fNewBlock); |
|
|
|
if (fNewBlock) |
|
|
|
if (fNewBlock) |
|
|
|
pfrom->nLastBlockTime = GetTime(); |
|
|
|
pfrom->nLastBlockTime = GetTime(); |
|
|
|
} |
|
|
|
} |
|
|
|