diff --git a/src/avalanche/proof.h b/src/avalanche/proof.h --- a/src/avalanche/proof.h +++ b/src/avalanche/proof.h @@ -111,6 +111,9 @@ ProofId proofid; void computeProofId(); + uint32_t score; + void computeScore(); + public: Proof() : sequence(0), expirationTime(0), master(), stakes(), @@ -124,6 +127,7 @@ payoutScriptPubKey(payoutScriptPubKey_), signature(std::move(signature_)) { computeProofId(); + computeScore(); } SERIALIZE_METHODS(Proof, obj) { @@ -132,6 +136,7 @@ READWRITE(obj.payoutScriptPubKey, obj.signature); } SER_READ(obj, obj.computeProofId()); + SER_READ(obj, obj.computeScore()); } static bool useLegacy(); @@ -154,7 +159,7 @@ const StakeCommitment getStakeCommitment() const { return StakeCommitment(proofid, expirationTime, master); }; - uint32_t getScore() const; + uint32_t getScore() const { return score; } bool verify(ProofValidationState &state) const; bool verify(ProofValidationState &state, const CCoinsView &view) const; diff --git a/src/avalanche/proof.cpp b/src/avalanche/proof.cpp --- a/src/avalanche/proof.cpp +++ b/src/avalanche/proof.cpp @@ -95,13 +95,13 @@ proofid = limitedProofId.computeProofId(master); } -uint32_t Proof::getScore() const { +void Proof::computeScore() { Amount total = Amount::zero(); for (const SignedStake &s : stakes) { total += s.getStake().getAmount(); } - return uint32_t((100 * total) / COIN); + score = uint32_t((100 * total) / COIN); } bool Proof::verify(ProofValidationState &state) const {