Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 908 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
}); | }); | ||||
}); | }); | ||||
return ret; | return ret; | ||||
}, | }, | ||||
}; | }; | ||||
} | } | ||||
static RPCHelpMan getavalancheproofs() { | |||||
return RPCHelpMan{ | |||||
"getavalancheproofs", | |||||
"Returns an object containing all tracked proofids.\n", | |||||
{}, | |||||
RPCResult{ | |||||
RPCResult::Type::OBJ, | |||||
"", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::ARR, | |||||
"valid", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::STR_HEX, "proofid", | |||||
"Avalanche proof id"}, | |||||
}}, | |||||
{RPCResult::Type::ARR, | |||||
"conflicting", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::STR_HEX, "proofid", | |||||
"Avalanche proof id"}, | |||||
}}, | |||||
{RPCResult::Type::ARR, | |||||
"immature", | |||||
"", | |||||
{ | |||||
{RPCResult::Type::STR_HEX, "proofid", | |||||
"Avalanche proof id"}, | |||||
}}, | |||||
}, | |||||
}, | |||||
RPCExamples{HelpExampleCli("getavalancheproofs", "") + | |||||
HelpExampleRpc("getavalancheproofs", "")}, | |||||
[&](const RPCHelpMan &self, const Config &config, | |||||
const JSONRPCRequest &request) -> UniValue { | |||||
if (!g_avalanche) { | |||||
throw JSONRPCError(RPC_INTERNAL_ERROR, | |||||
"Avalanche is not initialized"); | |||||
} | |||||
UniValue ret(UniValue::VOBJ); | |||||
g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | |||||
auto appendProofIds = [&ret](const avalanche::ProofPool &pool, | |||||
const std::string &key) { | |||||
UniValue arrOut(UniValue::VARR); | |||||
for (const avalanche::ProofId &proofid : | |||||
pool.getProofIds()) { | |||||
arrOut.push_back(proofid.ToString()); | |||||
} | |||||
ret.pushKV(key, arrOut); | |||||
}; | |||||
appendProofIds(pm.getValidProofPool(), "valid"); | |||||
appendProofIds(pm.getConflictingProofPool(), "conflicting"); | |||||
appendProofIds(pm.getImmatureProofPool(), "immature"); | |||||
}); | |||||
return ret; | |||||
}, | |||||
}; | |||||
} | |||||
static RPCHelpMan getrawavalancheproof() { | static RPCHelpMan getrawavalancheproof() { | ||||
return RPCHelpMan{ | return RPCHelpMan{ | ||||
"getrawavalancheproof", | "getrawavalancheproof", | ||||
"Lookup for a known avalanche proof by id.\n", | "Lookup for a known avalanche proof by id.\n", | ||||
{ | { | ||||
{"proofid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | {"proofid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, | ||||
"The hex encoded avalanche proof identifier."}, | "The hex encoded avalanche proof identifier."}, | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | static const CRPCCommand commands[] = { | ||||
{ "avalanche", getavalanchekey, }, | { "avalanche", getavalanchekey, }, | ||||
{ "avalanche", addavalanchenode, }, | { "avalanche", addavalanchenode, }, | ||||
{ "avalanche", buildavalancheproof, }, | { "avalanche", buildavalancheproof, }, | ||||
{ "avalanche", decodeavalancheproof, }, | { "avalanche", decodeavalancheproof, }, | ||||
{ "avalanche", delegateavalancheproof, }, | { "avalanche", delegateavalancheproof, }, | ||||
{ "avalanche", decodeavalanchedelegation, }, | { "avalanche", decodeavalanchedelegation, }, | ||||
{ "avalanche", getavalancheinfo, }, | { "avalanche", getavalancheinfo, }, | ||||
{ "avalanche", getavalanchepeerinfo, }, | { "avalanche", getavalanchepeerinfo, }, | ||||
{ "avalanche", getavalancheproofs, }, | |||||
{ "avalanche", getrawavalancheproof, }, | { "avalanche", getrawavalancheproof, }, | ||||
{ "avalanche", isfinalblock, }, | { "avalanche", isfinalblock, }, | ||||
{ "avalanche", isfinaltransaction, }, | { "avalanche", isfinaltransaction, }, | ||||
{ "avalanche", sendavalancheproof, }, | { "avalanche", sendavalancheproof, }, | ||||
{ "avalanche", verifyavalancheproof, }, | { "avalanche", verifyavalancheproof, }, | ||||
{ "avalanche", verifyavalanchedelegation, }, | { "avalanche", verifyavalanchedelegation, }, | ||||
}; | }; | ||||
// clang-format on | // clang-format on | ||||
for (const auto &c : commands) { | for (const auto &c : commands) { | ||||
t.appendCommand(c.name, &c); | t.appendCommand(c.name, &c); | ||||
} | } | ||||
} | } |