Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | static UniValue addavalanchenode(const Config &config, | ||||
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)) { | ||||
return false; | return false; | ||||
} | } | ||||
NodeContext &node = EnsureNodeContext(request.context); | NodeContext &node = EnsureNodeContext(request.context); | ||||
if (!node.connman->ForNode(nodeid, [&](CNode *pnode) { | if (!node.connman->ForNode(nodeid, [&](CNode *pnode) { | ||||
// FIXME This is not thread safe, and might cause issues if the | LOCK(pnode->cs_avalanche_state); | ||||
// unlikely event the peer sends an avahello message at the same | |||||
// time. | |||||
if (!pnode->m_avalanche_state) { | if (!pnode->m_avalanche_state) { | ||||
pnode->m_avalanche_state = | pnode->m_avalanche_state = | ||||
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; | ||||
▲ Show 20 Lines • Show All 519 Lines • Show Last 20 Lines |