Browse Source

Avoid holding cs_most_recent_block while calling ReadBlockFromDisk

0.14
Matt Corallo 8 years ago
parent
commit
c1ae4fcf7d
  1. 21
      src/net_processing.cpp

21
src/net_processing.cpp

@ -2894,15 +2894,20 @@ bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interruptMsg
int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS; int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
LOCK(cs_most_recent_block); bool fGotBlockFromCache = false;
if (most_recent_block_hash == pBestIndex->GetBlockHash()) { {
if (state.fWantsCmpctWitness) LOCK(cs_most_recent_block);
connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, *most_recent_compact_block)); if (most_recent_block_hash == pBestIndex->GetBlockHash()) {
else { if (state.fWantsCmpctWitness)
CBlockHeaderAndShortTxIDs cmpctblock(*most_recent_block, state.fWantsCmpctWitness); connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, *most_recent_compact_block));
connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock)); else {
CBlockHeaderAndShortTxIDs cmpctblock(*most_recent_block, state.fWantsCmpctWitness);
connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
}
fGotBlockFromCache = true;
} }
} else { }
if (!fGotBlockFromCache) {
CBlock block; CBlock block;
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams); bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
assert(ret); assert(ret);

Loading…
Cancel
Save