Avoid holding cs_most_recent_block while calling ReadBlockFromDisk
This commit is contained in:
parent
9eb67f5000
commit
c1ae4fcf7d
1 changed files with 13 additions and 8 deletions
|
@ -2894,6 +2894,8 @@ 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;
|
||||||
|
|
||||||
|
bool fGotBlockFromCache = false;
|
||||||
|
{
|
||||||
LOCK(cs_most_recent_block);
|
LOCK(cs_most_recent_block);
|
||||||
if (most_recent_block_hash == pBestIndex->GetBlockHash()) {
|
if (most_recent_block_hash == pBestIndex->GetBlockHash()) {
|
||||||
if (state.fWantsCmpctWitness)
|
if (state.fWantsCmpctWitness)
|
||||||
|
@ -2902,7 +2904,10 @@ bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interruptMsg
|
||||||
CBlockHeaderAndShortTxIDs cmpctblock(*most_recent_block, state.fWantsCmpctWitness);
|
CBlockHeaderAndShortTxIDs cmpctblock(*most_recent_block, state.fWantsCmpctWitness);
|
||||||
connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
|
connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
|
||||||
}
|
}
|
||||||
} else {
|
fGotBlockFromCache = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!fGotBlockFromCache) {
|
||||||
CBlock block;
|
CBlock block;
|
||||||
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
|
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
|
||||||
assert(ret);
|
assert(ret);
|
||||||
|
|
Loading…
Reference in a new issue