Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.cpp
| Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void Proof::computeScore() { | 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(); | ||||
| } | } | ||||
| score = uint32_t((100 * total) / COIN); | score = amountToScore(total); | ||||
| } | |||||
| uint32_t Proof::amountToScore(Amount amount) { | |||||
| return (100 * amount) / COIN; | |||||
| } | } | ||||
| Amount Proof::getStakedAmount() const { | Amount Proof::getStakedAmount() const { | ||||
| return std::accumulate(stakes.begin(), stakes.end(), Amount::zero(), | return std::accumulate(stakes.begin(), stakes.end(), Amount::zero(), | ||||
| [](const Amount current, const SignedStake &ss) { | [](const Amount current, const SignedStake &ss) { | ||||
| return current + ss.getStake().getAmount(); | return current + ss.getStake().getAmount(); | ||||
| }); | }); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 127 Lines • Show Last 20 Lines | |||||