Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/peermanager.cpp
Show All 13 Lines | |||||
namespace avalanche { | namespace avalanche { | ||||
static bool isOrphanState(const ProofValidationState &state) { | static bool isOrphanState(const ProofValidationState &state) { | ||||
return state.GetResult() == ProofValidationResult::MISSING_UTXO || | return state.GetResult() == ProofValidationResult::MISSING_UTXO || | ||||
state.GetResult() == ProofValidationResult::HEIGHT_MISMATCH; | state.GetResult() == ProofValidationResult::HEIGHT_MISMATCH; | ||||
} | } | ||||
bool PeerManager::addNode(NodeId nodeid, const Delegation &delegation) { | bool PeerManager::addNode(NodeId nodeid, const ProofId &proofid) { | ||||
auto &pview = peers.get<proof_index>(); | auto &pview = peers.get<proof_index>(); | ||||
auto it = pview.find(delegation.getProofId()); | auto it = pview.find(proofid); | ||||
if (it == pview.end()) { | if (it == pview.end()) { | ||||
return false; | return false; | ||||
} | } | ||||
DelegationState state; | |||||
CPubKey pubkey; | |||||
if (!delegation.verify(state, pubkey)) { | |||||
return false; | |||||
} | |||||
return addOrUpdateNode(peers.project<0>(it), nodeid); | return addOrUpdateNode(peers.project<0>(it), nodeid); | ||||
} | } | ||||
bool PeerManager::addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid) { | bool PeerManager::addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid) { | ||||
assert(it != peers.end()); | assert(it != peers.end()); | ||||
const PeerId peerid = it->peerid; | const PeerId peerid = it->peerid; | ||||
▲ Show 20 Lines • Show All 488 Lines • Show Last 20 Lines |