Merge #8968: Don't hold cs_main when calling ProcessNewBlock from a cmpctblock
72ca7d9
Don't hold cs_main when calling ProcessNewBlock from a cmpctblock (Matt Corallo)
This commit is contained in:
commit
3cf496d102
1 changed files with 27 additions and 22 deletions
|
@ -5828,6 +5828,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
BlockTransactions resp;
|
BlockTransactions resp;
|
||||||
vRecv >> resp;
|
vRecv >> resp;
|
||||||
|
|
||||||
|
CBlock block;
|
||||||
|
bool fBlockRead = false;
|
||||||
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
map<uint256, pair<NodeId, list<QueuedBlock>::iterator> >::iterator it = mapBlocksInFlight.find(resp.blockhash);
|
map<uint256, pair<NodeId, list<QueuedBlock>::iterator> >::iterator it = mapBlocksInFlight.find(resp.blockhash);
|
||||||
|
@ -5838,7 +5841,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
}
|
}
|
||||||
|
|
||||||
PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock;
|
PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock;
|
||||||
CBlock block;
|
|
||||||
ReadStatus status = partialBlock.FillBlock(block, resp.txn);
|
ReadStatus status = partialBlock.FillBlock(block, 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
|
||||||
|
@ -5850,7 +5852,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
std::vector<CInv> invs;
|
std::vector<CInv> invs;
|
||||||
invs.push_back(CInv(MSG_BLOCK | GetFetchFlags(pfrom, chainActive.Tip(), chainparams.GetConsensus()), resp.blockhash));
|
invs.push_back(CInv(MSG_BLOCK | GetFetchFlags(pfrom, chainActive.Tip(), chainparams.GetConsensus()), resp.blockhash));
|
||||||
pfrom->PushMessage(NetMsgType::GETDATA, invs);
|
pfrom->PushMessage(NetMsgType::GETDATA, invs);
|
||||||
} else {
|
} else
|
||||||
|
fBlockRead = true;
|
||||||
|
} // Don't hold cs_main when we call into ProcessNewBlock
|
||||||
|
if (fBlockRead) {
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
ProcessNewBlock(state, chainparams, pfrom, &block, false, NULL);
|
ProcessNewBlock(state, chainparams, pfrom, &block, false, NULL);
|
||||||
int nDoS;
|
int nDoS;
|
||||||
|
|
Loading…
Reference in a new issue