mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge 0be1dc1f56 into merged_master (Bitcoin PR bitcoin/bitcoin#24062)
This commit is contained in:
commit
57c149aa06
1 changed files with 6 additions and 5 deletions
|
|
@ -687,7 +687,7 @@ private:
|
|||
|
||||
|
||||
// All of the following cache a recent block, and are protected by m_most_recent_block_mutex
|
||||
RecursiveMutex m_most_recent_block_mutex;
|
||||
Mutex m_most_recent_block_mutex;
|
||||
std::shared_ptr<const CBlock> m_most_recent_block GUARDED_BY(m_most_recent_block_mutex);
|
||||
std::shared_ptr<const CBlockHeaderAndShortTxIDs> m_most_recent_compact_block GUARDED_BY(m_most_recent_block_mutex);
|
||||
uint256 m_most_recent_block_hash GUARDED_BY(m_most_recent_block_mutex);
|
||||
|
|
@ -4826,15 +4826,16 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
|||
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __func__,
|
||||
vHeaders.front().GetHash().ToString(), pto->GetId());
|
||||
|
||||
bool fGotBlockFromCache = false;
|
||||
std::optional<CSerializedNetMsg> cached_cmpctblock_msg;
|
||||
{
|
||||
LOCK(m_most_recent_block_mutex);
|
||||
if (m_most_recent_block_hash == pBestIndex->GetBlockHash()) {
|
||||
m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::CMPCTBLOCK, *m_most_recent_compact_block));
|
||||
fGotBlockFromCache = true;
|
||||
cached_cmpctblock_msg = msgMaker.Make(NetMsgType::CMPCTBLOCK, *m_most_recent_compact_block);
|
||||
}
|
||||
}
|
||||
if (!fGotBlockFromCache) {
|
||||
if (cached_cmpctblock_msg.has_value()) {
|
||||
m_connman.PushMessage(pto, std::move(cached_cmpctblock_msg.value()));
|
||||
} else {
|
||||
CBlock block;
|
||||
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams);
|
||||
assert(ret);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue