Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | if (!node.connman->ForNode(nodeid, [&](CNode *pnode) { | ||||
std::make_unique<CNode::AvalancheState>(); | std::make_unique<CNode::AvalancheState>(); | ||||
} | } | ||||
pnode->m_avalanche_state->pubkey = std::move(key); | pnode->m_avalanche_state->pubkey = std::move(key); | ||||
return true; | return true; | ||||
})) { | })) { | ||||
return false; | return false; | ||||
} | } | ||||
if (!g_avalanche->addNode(nodeid, proofid)) { | return g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
if (!pm.addNode(nodeid, proofid)) { | |||||
return false; | return false; | ||||
} | } | ||||
g_avalanche->addUnbroadcastProof(proofid); | pm.addUnbroadcastProof(proofid); | ||||
return true; | return true; | ||||
}); | |||||
} | } | ||||
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 444 Lines • ▼ Show 20 Lines | static UniValue sendavalancheproof(const Config &config, | ||||
// already is a proof with conflicting utxos. | // already is a proof with conflicting utxos. | ||||
const avalanche::ProofId &proofid = proof->getId(); | const avalanche::ProofId &proofid = proof->getId(); | ||||
if (!g_avalanche->getProof(proofid) && !g_avalanche->addProof(proof)) { | if (!g_avalanche->getProof(proofid) && !g_avalanche->addProof(proof)) { | ||||
throw JSONRPCError( | throw JSONRPCError( | ||||
RPC_INVALID_PARAMETER, | RPC_INVALID_PARAMETER, | ||||
"The proof has conflicting utxo with an existing proof"); | "The proof has conflicting utxo with an existing proof"); | ||||
} | } | ||||
g_avalanche->addUnbroadcastProof(proofid); | g_avalanche->withPeerManager( | ||||
[&](avalanche::PeerManager &pm) { pm.addUnbroadcastProof(proofid); }); | |||||
RelayProof(proofid, *node.connman); | RelayProof(proofid, *node.connman); | ||||
return true; | return true; | ||||
} | } | ||||
static UniValue verifyavalancheproof(const Config &config, | static UniValue verifyavalancheproof(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |