Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 797 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
RPCResult::Type::ARR, | RPCResult::Type::ARR, | ||||
"", | "", | ||||
"", | "", | ||||
{{ | {{ | ||||
RPCResult::Type::OBJ, | RPCResult::Type::OBJ, | ||||
"", | "", | ||||
"", | "", | ||||
{{ | {{ | ||||
{RPCResult::Type::NUM, "peerid", "The peer id"}, | {RPCResult::Type::NUM, "avalanche_peerid", | ||||
"The avalanche internal peer identifier"}, | |||||
{RPCResult::Type::STR_HEX, "proofid", | {RPCResult::Type::STR_HEX, "proofid", | ||||
"The avalanche proof id used by this peer"}, | "The avalanche proof id used by this peer"}, | ||||
{RPCResult::Type::STR_HEX, "proof", | {RPCResult::Type::STR_HEX, "proof", | ||||
"The avalanche proof used by this peer"}, | "The avalanche proof used by this peer"}, | ||||
{RPCResult::Type::NUM, "nodecount", | {RPCResult::Type::NUM, "nodecount", | ||||
"The number of nodes for this peer"}, | "The number of nodes for this peer"}, | ||||
{RPCResult::Type::ARR, | {RPCResult::Type::ARR, | ||||
"nodes", | "node_list", | ||||
"", | "", | ||||
{ | { | ||||
{RPCResult::Type::NUM, "nodeid", | {RPCResult::Type::NUM, "nodeid", | ||||
"Node id, as returned by getpeerinfo"}, | "Node id, as returned by getpeerinfo"}, | ||||
}}, | }}, | ||||
}}, | }}, | ||||
}}, | }}, | ||||
}, | }, | ||||
Show All 9 Lines | return RPCHelpMan{ | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, | throw JSONRPCError(RPC_INTERNAL_ERROR, | ||||
"Avalanche is not initialized"); | "Avalanche is not initialized"); | ||||
} | } | ||||
auto peerToUniv = [](const avalanche::PeerManager &pm, | auto peerToUniv = [](const avalanche::PeerManager &pm, | ||||
const avalanche::Peer &peer) { | const avalanche::Peer &peer) { | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
obj.pushKV("peerid", uint64_t(peer.peerid)); | obj.pushKV("avalanche_peerid", uint64_t(peer.peerid)); | ||||
obj.pushKV("proofid", peer.getProofId().ToString()); | obj.pushKV("proofid", peer.getProofId().ToString()); | ||||
obj.pushKV("proof", peer.proof->ToHex()); | obj.pushKV("proof", peer.proof->ToHex()); | ||||
UniValue nodes(UniValue::VARR); | UniValue nodes(UniValue::VARR); | ||||
pm.forEachNode(peer, [&](const avalanche::Node &n) { | pm.forEachNode(peer, [&](const avalanche::Node &n) { | ||||
nodes.push_back(n.nodeid); | nodes.push_back(n.nodeid); | ||||
}); | }); | ||||
obj.pushKV("nodecount", uint64_t(peer.node_count)); | obj.pushKV("nodecount", uint64_t(peer.node_count)); | ||||
obj.pushKV("nodes", nodes); | obj.pushKV("node_list", nodes); | ||||
return obj; | return obj; | ||||
}; | }; | ||||
UniValue ret(UniValue::VARR); | UniValue ret(UniValue::VARR); | ||||
g_avalanche->withPeerManager([&](const avalanche::PeerManager &pm) { | g_avalanche->withPeerManager([&](const avalanche::PeerManager &pm) { | ||||
// If a proofid is provided, only return the associated peer | // If a proofid is provided, only return the associated peer | ||||
▲ Show 20 Lines • Show All 206 Lines • Show Last 20 Lines |