Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/delegation.cpp
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | |||||
static bool reduceLevels(uint256 &hash, const std::vector<L> &levels) { | static bool reduceLevels(uint256 &hash, const std::vector<L> &levels) { | ||||
return reduceLevels(hash, levels, [](const L &) { return true; }); | return reduceLevels(hash, levels, [](const L &) { return true; }); | ||||
} | } | ||||
ProofId Delegation::getProofId() const { | ProofId Delegation::getProofId() const { | ||||
return limitedProofid.computeProofId(proofMaster); | return limitedProofid.computeProofId(proofMaster); | ||||
} | } | ||||
const CPubKey &Delegation::getDelegatedPubkey() const { | |||||
if (!levels.empty()) { | |||||
return levels.back().pubkey; | |||||
} | |||||
return proofMaster; | |||||
} | |||||
DelegationId Delegation::computeDelegationId() const { | DelegationId Delegation::computeDelegationId() const { | ||||
uint256 hash = getProofId(); | uint256 hash = getProofId(); | ||||
reduceLevels(hash, levels); | reduceLevels(hash, levels); | ||||
return DelegationId(hash); | return DelegationId(hash); | ||||
} | } | ||||
bool Delegation::verify(DelegationState &state, CPubKey &auth) const { | bool Delegation::verify(DelegationState &state, CPubKey &auth) const { | ||||
uint256 hash = getProofId(); | uint256 hash = getProofId(); | ||||
Show All 17 Lines |