Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 392 Lines • ▼ Show 20 Lines | RPCHelpMan{ | ||||
{{ | {{ | ||||
RPCResult::Type::OBJ, | RPCResult::Type::OBJ, | ||||
"", | "", | ||||
"", | "", | ||||
{{ | {{ | ||||
{RPCResult::Type::NUM, "peerid", "The peer id"}, | {RPCResult::Type::NUM, "peerid", "The peer id"}, | ||||
{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, "sequence", "The proof's sequence"}, | |||||
{RPCResult::Type::NUM_TIME, "expiration", | |||||
"The proof's expiration timestamp"}, | |||||
{RPCResult::Type::STR_HEX, "master", | |||||
"The proof's master public key"}, | |||||
{ | |||||
RPCResult::Type::ARR, | |||||
"stakes", | |||||
"", | |||||
{{ | |||||
RPCResult::Type::OBJ, | |||||
"", | |||||
"", | |||||
{{ | |||||
{RPCResult::Type::STR_HEX, "txid", ""}, | |||||
{RPCResult::Type::NUM, "vout", ""}, | |||||
{RPCResult::Type::STR_AMOUNT, "amount", | |||||
"The amount in this UTXO"}, | |||||
{RPCResult::Type::NUM, "height", | |||||
"The height at which this UTXO was mined"}, | |||||
{RPCResult::Type::BOOL, "iscoinbase", | |||||
"Indicate wether the UTXO is a coinbase"}, | |||||
{RPCResult::Type::STR_HEX, "pubkey", ""}, | |||||
}}, | |||||
}}, | |||||
}, | |||||
{RPCResult::Type::ARR, | {RPCResult::Type::ARR, | ||||
"nodes", | "nodes", | ||||
"", | "", | ||||
{ | { | ||||
{RPCResult::Type::NUM, "nodeid", | {RPCResult::Type::NUM, "nodeid", | ||||
"Node id, as returned by getpeerinfo"}, | "Node id, as returned by getpeerinfo"}, | ||||
}}, | }}, | ||||
}}, | }}, | ||||
Show All 13 Lines | static UniValue getavalanchepeerinfo(const Config &config, | ||||
for (const auto &peer : g_avalanche->getPeers()) { | for (const auto &peer : g_avalanche->getPeers()) { | ||||
UniValue obj(UniValue::VOBJ); | UniValue obj(UniValue::VOBJ); | ||||
CDataStream serproof(SER_NETWORK, PROTOCOL_VERSION); | CDataStream serproof(SER_NETWORK, PROTOCOL_VERSION); | ||||
serproof << peer.proof; | serproof << peer.proof; | ||||
obj.pushKV("peerid", uint64_t(peer.peerid)); | obj.pushKV("peerid", uint64_t(peer.peerid)); | ||||
obj.pushKV("proof", HexStr(serproof)); | obj.pushKV("proof", HexStr(serproof)); | ||||
obj.pushKV("sequence", peer.proof.getSequence()); | |||||
obj.pushKV("expiration", peer.proof.getExpirationTime()); | |||||
obj.pushKV("master", HexStr(peer.proof.getMaster())); | |||||
UniValue stakes(UniValue::VARR); | |||||
for (const auto &s : peer.proof.getStakes()) { | |||||
UniValue stake(UniValue::VOBJ); | |||||
stake.pushKV("txid", s.getStake().getUTXO().GetTxId().GetHex()); | |||||
stake.pushKV("vout", uint64_t(s.getStake().getUTXO().GetN())); | |||||
stake.pushKV("amount", ValueFromAmount(s.getStake().getAmount())); | |||||
stake.pushKV("height", uint64_t(s.getStake().getHeight())); | |||||
stake.pushKV("iscoinbase", s.getStake().isCoinbase()); | |||||
stake.pushKV("pubkey", HexStr(s.getStake().getPubkey())); | |||||
stakes.push_back(stake); | |||||
} | |||||
obj.pushKV("stakes", stakes); | |||||
UniValue nodes(UniValue::VARR); | UniValue nodes(UniValue::VARR); | ||||
for (const auto &id : g_avalanche->getNodeIdsForPeer(peer.peerid)) { | for (const auto &id : g_avalanche->getNodeIdsForPeer(peer.peerid)) { | ||||
nodes.push_back(id); | nodes.push_back(id); | ||||
} | } | ||||
obj.pushKV("nodes", nodes); | obj.pushKV("nodes", nodes); | ||||
obj.pushKV("nodecount", uint64_t(peer.node_count)); | obj.pushKV("nodecount", uint64_t(peer.node_count)); | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |