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,739 Lines • ▼ Show 20 Lines | void PeerManagerImpl::AvalanchePeriodicNetworking(CScheduler &scheduler) const { | ||||
} | } | ||||
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 | |||||
// subset of our peers as we expect a ton of avaproofs message in the | |||||
// process. | |||||
if (g_avalanche->getAvaproofsNodeCounter() == 0) { | |||||
avanode_outbound_ids.resize( | |||||
std::min<size_t>(avanode_outbound_ids.size(), 3)); | |||||
} | |||||
for (NodeId nodeid : avanode_outbound_ids) { | |||||
// Send a getavaproofs to one of our peers | // Send a getavaproofs to one of our peers | ||||
m_connman.ForNode(avanode_outbound_ids.back(), [&](CNode *pavanode) { | m_connman.ForNode(nodeid, [&](CNode *pavanode) { | ||||
LogPrint(BCLog::AVALANCHE, "Requesting compact proofs from peer %d\n", | LogPrint(BCLog::AVALANCHE, | ||||
"Requesting compact proofs from peer %d\n", | |||||
pavanode->GetId()); | pavanode->GetId()); | ||||
m_connman.PushMessage(pavanode, | m_connman.PushMessage(pavanode, | ||||
CNetMsgMaker(pavanode->GetCommonVersion()) | CNetMsgMaker(pavanode->GetCommonVersion()) | ||||
.Make(NetMsgType::GETAVAPROOFS)); | .Make(NetMsgType::GETAVAPROOFS)); | ||||
return true; | return true; | ||||
}); | }); | ||||
} | |||||
scheduleLater: | scheduleLater: | ||||
// Schedule next run for 2-5 minutes in the future. | // Schedule next run for 2-5 minutes in the future. | ||||
// We add randomness on every cycle to avoid the possibility of P2P | // We add randomness on every cycle to avoid the possibility of P2P | ||||
// fingerprinting. | // fingerprinting. | ||||
const auto avalanchePeriodicNetworkingInterval = 2min + GetRandMillis(3min); | const auto avalanchePeriodicNetworkingInterval = 2min + GetRandMillis(3min); | ||||
sdulfari: Due to this interval, if the 3 randomly selected peers didn't give good compact proofs, the… | |||||
FabienAuthorUnsubmitted Done Inline ActionsIf you had no answer within the interval from any of the 3 peers, which is unlikely, it's probably best to wait a bit before retrying:
I don't think lowering the interval will really help, and it's only a few minutes. Fabien: If you had no answer within the interval from any of the 3 peers, which is unlikely, it's… | |||||
scheduler.scheduleFromNow([&] { AvalanchePeriodicNetworking(scheduler); }, | scheduler.scheduleFromNow([&] { AvalanchePeriodicNetworking(scheduler); }, | ||||
avalanchePeriodicNetworkingInterval); | avalanchePeriodicNetworkingInterval); | ||||
} | } | ||||
void PeerManagerImpl::FinalizeNode(const Config &config, const CNode &node, | void PeerManagerImpl::FinalizeNode(const Config &config, const CNode &node, | ||||
bool &fUpdateConnectionTime) { | bool &fUpdateConnectionTime) { | ||||
NodeId nodeid = node.GetId(); | NodeId nodeid = node.GetId(); | ||||
fUpdateConnectionTime = false; | fUpdateConnectionTime = false; | ||||
▲ Show 20 Lines • Show All 5,331 Lines • Show Last 20 Lines |
Due to this interval, if the 3 randomly selected peers didn't give good compact proofs, the node will sit for many minutes until requesting again. Does it make sense to shorten this interval much shorter until getAvaproofsNodeCounter() > 0?