Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/processor.cpp
Show First 20 Lines • Show All 771 Lines • ▼ Show 20 Lines | |||||
* Returns a bool indicating whether we have a usable Avalanche quorum enabling | * Returns a bool indicating whether we have a usable Avalanche quorum enabling | ||||
* us to take decisions based on polls. | * us to take decisions based on polls. | ||||
*/ | */ | ||||
bool Processor::isQuorumEstablished() { | bool Processor::isQuorumEstablished() { | ||||
if (quorumIsEstablished) { | if (quorumIsEstablished) { | ||||
return true; | return true; | ||||
} | } | ||||
auto localProof = getLocalProof(); | |||||
// Get the registered proof score and registered score we have nodes for | // Get the registered proof score and registered score we have nodes for | ||||
uint32_t totalPeersScore; | uint32_t totalPeersScore; | ||||
uint32_t connectedPeersScore; | uint32_t connectedPeersScore; | ||||
{ | { | ||||
LOCK(cs_peerManager); | LOCK(cs_peerManager); | ||||
totalPeersScore = peerManager->getTotalPeersScore(); | totalPeersScore = peerManager->getTotalPeersScore(); | ||||
connectedPeersScore = peerManager->getConnectedPeersScore(); | connectedPeersScore = peerManager->getConnectedPeersScore(); | ||||
// Consider that we are always connected to our proof, even if we are | |||||
// the single node using that proof. | |||||
if (localProof && | |||||
peerManager->forPeer(localProof->getId(), [](const Peer &peer) { | |||||
return peer.node_count == 0; | |||||
})) { | |||||
connectedPeersScore += localProof->getScore(); | |||||
} | |||||
} | } | ||||
// Ensure enough is being staked overall | // Ensure enough is being staked overall | ||||
if (totalPeersScore < minQuorumScore) { | if (totalPeersScore < minQuorumScore) { | ||||
return false; | return false; | ||||
} | } | ||||
// Ensure we have connected score for enough of the overall score | // Ensure we have connected score for enough of the overall score | ||||
Show All 16 Lines |