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,688 Lines • ▼ Show 20 Lines | void PeerManagerImpl::ReattemptInitialBroadcast(CScheduler &scheduler) { | ||||
scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, | scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, | ||||
reattemptBroadcastInterval); | reattemptBroadcastInterval); | ||||
} | } | ||||
void PeerManagerImpl::UpdateAvalancheStatistics() const { | void PeerManagerImpl::UpdateAvalancheStatistics() const { | ||||
m_connman.ForEachNode([](CNode *pnode) { | m_connman.ForEachNode([](CNode *pnode) { | ||||
pnode->updateAvailabilityScore(AVALANCHE_STATISTICS_DECAY_FACTOR); | pnode->updateAvailabilityScore(AVALANCHE_STATISTICS_DECAY_FACTOR); | ||||
}); | }); | ||||
if (!g_avalanche) { | |||||
// Not enabled or not ready yet | |||||
return; | |||||
} | |||||
// Generate a peer availability score by computing an exponentially | |||||
// weighted moving average of the average of node availability scores. | |||||
// This ensures the peer score is bound to the lifetime of its proof which | |||||
// incentivizes stable network activity. | |||||
g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | |||||
pm.updateAvailabilityScores( | |||||
AVALANCHE_STATISTICS_DECAY_FACTOR, [&](NodeId nodeid) -> double { | |||||
double score{0.0}; | |||||
m_connman.ForNode(nodeid, [&](CNode *pavanode) { | |||||
score = pavanode->getAvailabilityScore(); | |||||
return true; | |||||
}); | |||||
return score; | |||||
}); | |||||
}); | |||||
} | } | ||||
void PeerManagerImpl::AvalanchePeriodicNetworking(CScheduler &scheduler) const { | void PeerManagerImpl::AvalanchePeriodicNetworking(CScheduler &scheduler) const { | ||||
const auto now = GetTime<std::chrono::seconds>(); | const auto now = GetTime<std::chrono::seconds>(); | ||||
std::vector<NodeId> avanode_ids; | std::vector<NodeId> avanode_ids; | ||||
bool fQuorumEstablished; | bool fQuorumEstablished; | ||||
bool fShouldRequestMoreNodes; | bool fShouldRequestMoreNodes; | ||||
▲ Show 20 Lines • Show All 5,536 Lines • Show Last 20 Lines |