Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | static UniValue addavalanchenode(const Config &config, | ||||
if (!g_avalanche) { | if (!g_avalanche) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Avalanche is not initialized"); | throw JSONRPCError(RPC_INTERNAL_ERROR, "Avalanche is not initialized"); | ||||
} | } | ||||
const NodeId nodeid = request.params[0].get_int64(); | const NodeId nodeid = request.params[0].get_int64(); | ||||
const CPubKey key = ParsePubKey(request.params[1]); | const CPubKey key = ParsePubKey(request.params[1]); | ||||
avalanche::Proof proof; | auto proof = std::make_shared<avalanche::Proof>(); | ||||
bilingual_str error; | bilingual_str error; | ||||
if (!avalanche::Proof::FromHex(proof, request.params[2].get_str(), error)) { | if (!avalanche::Proof::FromHex(*proof, request.params[2].get_str(), | ||||
error)) { | |||||
throw JSONRPCError(RPC_INVALID_PARAMETER, error.original); | throw JSONRPCError(RPC_INVALID_PARAMETER, error.original); | ||||
} | } | ||||
if (key != proof.getMaster()) { | if (key != proof->getMaster()) { | ||||
// TODO: we want to provide a proper delegation. | // TODO: we want to provide a proper delegation. | ||||
return false; | return false; | ||||
} | } | ||||
return g_avalanche->addNode(nodeid, proof, | return g_avalanche->addNode(nodeid, proof, | ||||
avalanche::DelegationBuilder(proof).build()); | avalanche::DelegationBuilder(*proof).build()); | ||||
} | } | ||||
static UniValue buildavalancheproof(const Config &config, | static UniValue buildavalancheproof(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"buildavalancheproof", | "buildavalancheproof", | ||||
"Build a proof for avalanche's sybil resistance.\n", | "Build a proof for avalanche's sybil resistance.\n", | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 406 Lines • Show Last 20 Lines |