Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
if (!g_avalanche) { | if (!g_avalanche) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, | throw JSONRPCError(RPC_INTERNAL_ERROR, | ||||
"Avalanche is not initialized"); | "Avalanche is not initialized"); | ||||
} | } | ||||
const NodeId nodeid = request.params[0].get_int64(); | const NodeId nodeid = request.params[0].get_int64(); | ||||
CPubKey key = ParsePubKey(request.params[1]); | CPubKey key = ParsePubKey(request.params[1]); | ||||
auto proof = std::make_shared<avalanche::Proof>(); | auto proof = RCUPtr<avalanche::Proof>::make(); | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
verifyProofOrThrow(node, *proof, request.params[2].get_str()); | verifyProofOrThrow(node, *proof, request.params[2].get_str()); | ||||
const avalanche::ProofId &proofid = proof->getId(); | const avalanche::ProofId &proofid = proof->getId(); | ||||
if (key != proof->getMaster()) { | if (key != proof->getMaster()) { | ||||
if (request.params.size() < 4 || request.params[3].isNull()) { | if (request.params.size() < 4 || request.params[3].isNull()) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_ADDRESS_OR_KEY, | RPC_INVALID_ADDRESS_OR_KEY, | ||||
▲ Show 20 Lines • Show All 797 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
RPCExamples{HelpExampleRpc("sendavalancheproof", "<proof>")}, | RPCExamples{HelpExampleRpc("sendavalancheproof", "<proof>")}, | ||||
[&](const RPCHelpMan &self, const Config &config, | [&](const RPCHelpMan &self, const Config &config, | ||||
const JSONRPCRequest &request) -> UniValue { | const JSONRPCRequest &request) -> UniValue { | ||||
if (!g_avalanche) { | if (!g_avalanche) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, | throw JSONRPCError(RPC_INTERNAL_ERROR, | ||||
"Avalanche is not initialized"); | "Avalanche is not initialized"); | ||||
} | } | ||||
auto proof = std::make_shared<avalanche::Proof>(); | auto proof = RCUPtr<avalanche::Proof>::make(); | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
// Verify the proof. Note that this is redundant with the | // Verify the proof. Note that this is redundant with the | ||||
// verification done when adding the proof to the pool, but we get a | // verification done when adding the proof to the pool, but we get a | ||||
// chance to give a better error message. | // chance to give a better error message. | ||||
verifyProofOrThrow(node, *proof, request.params[0].get_str()); | verifyProofOrThrow(node, *proof, request.params[0].get_str()); | ||||
// Add the proof to the pool if we don't have it already. Since the | // Add the proof to the pool if we don't have it already. Since the | ||||
▲ Show 20 Lines • Show All 94 Lines • Show Last 20 Lines |