Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.cpp
Show First 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | void Proof::computeProofId() { | ||||
for (const SignedStake &s : stakes) { | for (const SignedStake &s : stakes) { | ||||
ss << s.getStake(); | ss << s.getStake(); | ||||
} | } | ||||
limitedProofId = LimitedProofId(ss.GetHash()); | limitedProofId = LimitedProofId(ss.GetHash()); | ||||
proofid = limitedProofId.computeProofId(master); | proofid = limitedProofId.computeProofId(master); | ||||
} | } | ||||
uint32_t Proof::getScore() const { | void Proof::computeScore() { | ||||
Amount total = Amount::zero(); | Amount total = Amount::zero(); | ||||
for (const SignedStake &s : stakes) { | for (const SignedStake &s : stakes) { | ||||
total += s.getStake().getAmount(); | total += s.getStake().getAmount(); | ||||
} | } | ||||
return uint32_t((100 * total) / COIN); | score = uint32_t((100 * total) / COIN); | ||||
} | } | ||||
bool Proof::verify(ProofValidationState &state) const { | bool Proof::verify(ProofValidationState &state) const { | ||||
if (stakes.empty()) { | if (stakes.empty()) { | ||||
return state.Invalid(ProofValidationResult::NO_STAKE, "no-stake"); | return state.Invalid(ProofValidationResult::NO_STAKE, "no-stake"); | ||||
} | } | ||||
if (stakes.size() > AVALANCHE_MAX_PROOF_STAKES) { | if (stakes.size() > AVALANCHE_MAX_PROOF_STAKES) { | ||||
▲ Show 20 Lines • Show All 120 Lines • Show Last 20 Lines |