Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 508 Lines • ▼ Show 20 Lines | static UniValue getrawavalancheproof(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 avalanche::ProofId proofid = | const avalanche::ProofId proofid = | ||||
avalanche::ProofId::fromHex(request.params[0].get_str()); | avalanche::ProofId::fromHex(request.params[0].get_str()); | ||||
bool isOrphan = false; | bool isOrphan = false; | ||||
auto proof = g_avalanche->getProof(proofid); | auto proof = g_avalanche->withPeerManager([&](avalanche::PeerManager &pm) { | ||||
auto proof = pm.getProof(proofid); | |||||
if (!proof) { | if (!proof) { | ||||
proof = g_avalanche->getOrphan(proofid); | proof = pm.getOrphan(proofid); | ||||
isOrphan = true; | isOrphan = true; | ||||
} | } | ||||
return proof; | |||||
}); | |||||
if (!proof) { | if (!proof) { | ||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Proof not found"); | throw JSONRPCError(RPC_INVALID_PARAMETER, "Proof not found"); | ||||
} | } | ||||
UniValue ret(UniValue::VOBJ); | UniValue ret(UniValue::VOBJ); | ||||
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); | CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); | ||||
▲ Show 20 Lines • Show All 115 Lines • Show Last 20 Lines |