@@ -2894,15 +2894,20 @@ bool SendMessages(CNode* pto, CConnman& connman, std::atomic<bool>& interruptMsg
2894
2894
2895
2895
int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
2896
2896
2897
- LOCK (cs_most_recent_block);
2898
- if (most_recent_block_hash == pBestIndex->GetBlockHash ()) {
2899
- if (state.fWantsCmpctWitness )
2900
- connman.PushMessage (pto, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, *most_recent_compact_block));
2901
- else {
2902
- CBlockHeaderAndShortTxIDs cmpctblock (*most_recent_block, state.fWantsCmpctWitness );
2903
- connman.PushMessage (pto, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
2897
+ bool fGotBlockFromCache = false ;
2898
+ {
2899
+ LOCK (cs_most_recent_block);
2900
+ if (most_recent_block_hash == pBestIndex->GetBlockHash ()) {
2901
+ if (state.fWantsCmpctWitness )
2902
+ connman.PushMessage (pto, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, *most_recent_compact_block));
2903
+ else {
2904
+ CBlockHeaderAndShortTxIDs cmpctblock (*most_recent_block, state.fWantsCmpctWitness );
2905
+ connman.PushMessage (pto, msgMaker.Make (nSendFlags, NetMsgType::CMPCTBLOCK, cmpctblock));
2906
+ }
2907
+ fGotBlockFromCache = true ;
2904
2908
}
2905
- } else {
2909
+ }
2910
+ if (!fGotBlockFromCache ) {
2906
2911
CBlock block;
2907
2912
bool ret = ReadBlockFromDisk (block, pBestIndex, consensusParams);
2908
2913
assert (ret);
0 commit comments