|
|
@ -41,6 +41,7 @@
|
|
|
|
#include <algorithm>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <atomic>
|
|
|
|
#include <atomic>
|
|
|
|
#include <chrono>
|
|
|
|
#include <chrono>
|
|
|
|
|
|
|
|
#include <future>
|
|
|
|
#include <memory>
|
|
|
|
#include <memory>
|
|
|
|
#include <optional>
|
|
|
|
#include <optional>
|
|
|
|
#include <typeinfo>
|
|
|
|
#include <typeinfo>
|
|
|
@ -1596,6 +1597,8 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
|
|
|
|
|
|
|
|
|
|
|
|
bool fWitnessEnabled = DeploymentActiveAt(*pindex, m_chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT);
|
|
|
|
bool fWitnessEnabled = DeploymentActiveAt(*pindex, m_chainparams.GetConsensus(), Consensus::DEPLOYMENT_SEGWIT);
|
|
|
|
uint256 hashBlock(pblock->GetHash());
|
|
|
|
uint256 hashBlock(pblock->GetHash());
|
|
|
|
|
|
|
|
const std::shared_future<CSerializedNetMsg> lazy_ser{
|
|
|
|
|
|
|
|
std::async(std::launch::deferred, [&] { return msgMaker.Make(NetMsgType::CMPCTBLOCK, *pcmpctblock); })};
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK(cs_most_recent_block);
|
|
|
|
LOCK(cs_most_recent_block);
|
|
|
@ -1605,10 +1608,9 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
|
|
|
|
fWitnessesPresentInMostRecentCompactBlock = fWitnessEnabled;
|
|
|
|
fWitnessesPresentInMostRecentCompactBlock = fWitnessEnabled;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_connman.ForEachNode([this, &pcmpctblock, pindex, &msgMaker, fWitnessEnabled, &hashBlock](CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
|
|
|
m_connman.ForEachNode([this, pindex, fWitnessEnabled, &lazy_ser, &hashBlock](CNode* pnode) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
|
|
|
|
AssertLockHeld(::cs_main);
|
|
|
|
AssertLockHeld(::cs_main);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Avoid the repeated-serialization here
|
|
|
|
|
|
|
|
if (pnode->GetCommonVersion() < INVALID_CB_NO_BAN_VERSION || pnode->fDisconnect)
|
|
|
|
if (pnode->GetCommonVersion() < INVALID_CB_NO_BAN_VERSION || pnode->fDisconnect)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
ProcessBlockAvailability(pnode->GetId());
|
|
|
|
ProcessBlockAvailability(pnode->GetId());
|
|
|
@ -1620,7 +1622,9 @@ void PeerManagerImpl::NewPoWValidBlock(const CBlockIndex *pindex, const std::sha
|
|
|
|
|
|
|
|
|
|
|
|
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerManager::NewPoWValidBlock",
|
|
|
|
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerManager::NewPoWValidBlock",
|
|
|
|
hashBlock.ToString(), pnode->GetId());
|
|
|
|
hashBlock.ToString(), pnode->GetId());
|
|
|
|
m_connman.PushMessage(pnode, msgMaker.Make(NetMsgType::CMPCTBLOCK, *pcmpctblock));
|
|
|
|
|
|
|
|
|
|
|
|
const CSerializedNetMsg& ser_cmpctblock{lazy_ser.get()};
|
|
|
|
|
|
|
|
m_connman.PushMessage(pnode, CSerializedNetMsg{ser_cmpctblock.data, ser_cmpctblock.m_type});
|
|
|
|
state.pindexBestHeaderSent = pindex;
|
|
|
|
state.pindexBestHeaderSent = pindex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|