Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 1,710 Lines • ▼ Show 20 Lines | void PeerManagerImpl::AvalanchePeriodicNetworking(CScheduler &scheduler) const { | ||||
} | } | ||||
Shuffle(avanode_ids.begin(), avanode_ids.end(), FastRandomContext()); | Shuffle(avanode_ids.begin(), avanode_ids.end(), FastRandomContext()); | ||||
if (!fQuorumEstablished || | if (!fQuorumEstablished || | ||||
g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
return pm.shouldRequestMoreNodes(); | return pm.shouldRequestMoreNodes(); | ||||
})) { | })) { | ||||
// Randomly select an avalanche peer to send the getavaaddr message to | // Randomly select 3 avalanche peer to send the getavaaddr message to | ||||
const NodeId avanodeId = avanode_ids.front(); | for (size_t i = 0; i < 3; i++) { | ||||
if (avanode_ids.size() <= i) { | |||||
break; | |||||
} | |||||
const NodeId avanodeId = avanode_ids[i]; | |||||
m_connman.ForNode(avanodeId, [&](CNode *pavanode) { | m_connman.ForNode(avanodeId, [&](CNode *pavanode) { | ||||
LogPrint(BCLog::AVALANCHE, | LogPrint(BCLog::AVALANCHE, | ||||
"Requesting more avalanche addresses from peer %d\n", | "Requesting more avalanche addresses from peer %d\n", | ||||
avanodeId); | avanodeId); | ||||
m_connman.PushMessage(pavanode, | m_connman.PushMessage(pavanode, | ||||
CNetMsgMaker(pavanode->GetCommonVersion()) | CNetMsgMaker(pavanode->GetCommonVersion()) | ||||
.Make(NetMsgType::GETAVAADDR)); | .Make(NetMsgType::GETAVAADDR)); | ||||
PeerRef peer = GetPeerRef(avanodeId); | PeerRef peer = GetPeerRef(avanodeId); | ||||
WITH_LOCK(peer->m_addr_token_bucket_mutex, | WITH_LOCK(peer->m_addr_token_bucket_mutex, | ||||
peer->m_addr_token_bucket += GetMaxAddrToSend()); | peer->m_addr_token_bucket += GetMaxAddrToSend()); | ||||
return true; | return true; | ||||
}); | }); | ||||
} | } | ||||
} | |||||
if (m_chainman.ActiveChainstate().IsInitialBlockDownload()) { | if (m_chainman.ActiveChainstate().IsInitialBlockDownload()) { | ||||
// Don't request proofs while in IBD. We're likely to orphan them | // Don't request proofs while in IBD. We're likely to orphan them | ||||
// because we don't have the UTXOs. | // because we don't have the UTXOs. | ||||
goto scheduleLater; | goto scheduleLater; | ||||
} | } | ||||
// If we never had an avaproofs message yet, be kind and only request to a | // If we never had an avaproofs message yet, be kind and only request to a | ||||
▲ Show 20 Lines • Show All 5,384 Lines • Show Last 20 Lines |