Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 664 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
"network", | "network", | ||||
"", | "", | ||||
{ | { | ||||
{RPCResult::Type::NUM, "proof_count", | {RPCResult::Type::NUM, "proof_count", | ||||
"The number of valid avalanche proofs we know exist."}, | "The number of valid avalanche proofs we know exist."}, | ||||
{RPCResult::Type::NUM, "connected_proof_count", | {RPCResult::Type::NUM, "connected_proof_count", | ||||
"The number of avalanche proofs with at least one node " | "The number of avalanche proofs with at least one node " | ||||
"we are connected to."}, | "we are connected to."}, | ||||
{RPCResult::Type::NUM, "conflicting_proof_count", | |||||
"The number of known avalanche proofs that conflict with " | |||||
"valid proofs."}, | |||||
{RPCResult::Type::STR_AMOUNT, "total_stake_amount", | {RPCResult::Type::STR_AMOUNT, "total_stake_amount", | ||||
"The total staked amount over all the valid proofs in " + | "The total staked amount over all the valid proofs in " + | ||||
Currency::get().ticker + "."}, | Currency::get().ticker + "."}, | ||||
{RPCResult::Type::STR_AMOUNT, "connected_stake_amount", | {RPCResult::Type::STR_AMOUNT, "connected_stake_amount", | ||||
"The total staked amount over all the connected proofs " | "The total staked amount over all the connected proofs " | ||||
"in " + | "in " + | ||||
Currency::get().ticker + "."}, | Currency::get().ticker + "."}, | ||||
{RPCResult::Type::NUM, "node_count", | {RPCResult::Type::NUM, "node_count", | ||||
Show All 35 Lines | return RPCHelpMan{ | ||||
destination)) { | destination)) { | ||||
local.pushKV("payout_address", | local.pushKV("payout_address", | ||||
EncodeDestination(destination, config)); | EncodeDestination(destination, config)); | ||||
} | } | ||||
local.pushKV("stake_amount", localProof->getStakedAmount()); | local.pushKV("stake_amount", localProof->getStakedAmount()); | ||||
ret.pushKV("local", local); | ret.pushKV("local", local); | ||||
} | } | ||||
g_avalanche->withPeerManager([&](const 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}; | ||||
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) { | ||||
Show All 12 Lines | return RPCHelpMan{ | ||||
if (peer.node_count > 0) { | if (peer.node_count > 0) { | ||||
++connectedProofCount; | ++connectedProofCount; | ||||
connectedStakes += proofStake; | connectedStakes += proofStake; | ||||
} | } | ||||
}); | }); | ||||
network.pushKV("proof_count", proofCount); | network.pushKV("proof_count", proofCount); | ||||
network.pushKV("connected_proof_count", connectedProofCount); | network.pushKV("connected_proof_count", connectedProofCount); | ||||
network.pushKV("conflicting_proof_count", | |||||
pm.getConflictingProofCount()); | |||||
network.pushKV("total_stake_amount", totalStakes); | network.pushKV("total_stake_amount", totalStakes); | ||||
network.pushKV("connected_stake_amount", connectedStakes); | network.pushKV("connected_stake_amount", connectedStakes); | ||||
const uint64_t connectedNodes = pm.getNodeCount(); | 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", connectedNodes + pendingNodes); | ||||
network.pushKV("connected_node_count", connectedNodes); | network.pushKV("connected_node_count", connectedNodes); | ||||
network.pushKV("pending_node_count", pendingNodes); | network.pushKV("pending_node_count", pendingNodes); | ||||
▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines |