Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 729 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
} | } | ||||
g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
UniValue network(UniValue::VOBJ); | UniValue network(UniValue::VOBJ); | ||||
uint64_t proofCount{0}; | uint64_t proofCount{0}; | ||||
uint64_t connectedProofCount{0}; | uint64_t connectedProofCount{0}; | ||||
uint64_t finalizedProofCount{0}; | uint64_t finalizedProofCount{0}; | ||||
uint64_t connectedNodeCount{0}; | |||||
Amount totalStakes = Amount::zero(); | Amount totalStakes = Amount::zero(); | ||||
Amount connectedStakes = Amount::zero(); | Amount connectedStakes = Amount::zero(); | ||||
pm.forEachPeer([&](const avalanche::Peer &peer) { | pm.forEachPeer([&](const avalanche::Peer &peer) { | ||||
CHECK_NONFATAL(peer.proof != nullptr); | CHECK_NONFATAL(peer.proof != nullptr); | ||||
// Don't account for our local proof here | // Don't account for our local proof here | ||||
if (peer.proof == localProof) { | if (peer.proof == localProof) { | ||||
return; | return; | ||||
} | } | ||||
const Amount proofStake = peer.proof->getStakedAmount(); | const Amount proofStake = peer.proof->getStakedAmount(); | ||||
++proofCount; | ++proofCount; | ||||
totalStakes += proofStake; | totalStakes += proofStake; | ||||
if (peer.hasFinalized) { | if (peer.hasFinalized) { | ||||
++finalizedProofCount; | ++finalizedProofCount; | ||||
} | } | ||||
if (peer.node_count > 0) { | if (peer.node_count > 0) { | ||||
++connectedProofCount; | ++connectedProofCount; | ||||
connectedStakes += proofStake; | connectedStakes += proofStake; | ||||
} | } | ||||
connectedNodeCount += peer.node_count; | |||||
}); | }); | ||||
network.pushKV("proof_count", proofCount); | network.pushKV("proof_count", proofCount); | ||||
network.pushKV("connected_proof_count", connectedProofCount); | network.pushKV("connected_proof_count", connectedProofCount); | ||||
network.pushKV("dangling_proof_count", | network.pushKV("dangling_proof_count", | ||||
proofCount - connectedProofCount); | proofCount - connectedProofCount); | ||||
network.pushKV("finalized_proof_count", finalizedProofCount); | network.pushKV("finalized_proof_count", finalizedProofCount); | ||||
network.pushKV("conflicting_proof_count", | network.pushKV("conflicting_proof_count", | ||||
uint64_t(pm.getConflictingProofCount())); | uint64_t(pm.getConflictingProofCount())); | ||||
network.pushKV("orphan_proof_count", | network.pushKV("orphan_proof_count", | ||||
uint64_t(pm.getOrphanProofCount())); | uint64_t(pm.getOrphanProofCount())); | ||||
network.pushKV("total_stake_amount", totalStakes); | network.pushKV("total_stake_amount", totalStakes); | ||||
network.pushKV("connected_stake_amount", connectedStakes); | network.pushKV("connected_stake_amount", connectedStakes); | ||||
network.pushKV("dangling_stake_amount", | network.pushKV("dangling_stake_amount", | ||||
totalStakes - connectedStakes); | totalStakes - connectedStakes); | ||||
const uint64_t connectedNodes = pm.getNodeCount(); | |||||
const uint64_t pendingNodes = pm.getPendingNodeCount(); | const uint64_t pendingNodes = pm.getPendingNodeCount(); | ||||
network.pushKV("node_count", connectedNodes + pendingNodes); | network.pushKV("node_count", connectedNodeCount + pendingNodes); | ||||
network.pushKV("connected_node_count", connectedNodes); | network.pushKV("connected_node_count", connectedNodeCount); | ||||
network.pushKV("pending_node_count", pendingNodes); | network.pushKV("pending_node_count", pendingNodes); | ||||
ret.pushKV("network", network); | ret.pushKV("network", network); | ||||
}); | }); | ||||
return ret; | return ret; | ||||
}, | }, | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 280 Lines • Show Last 20 Lines |