diff --git a/src/avalanche/proof.h b/src/avalanche/proof.h --- a/src/avalanche/proof.h +++ b/src/avalanche/proof.h @@ -85,6 +85,9 @@ ProofId proofid; void computeProofId(); + uint32_t score; + void computeScore(); + public: Proof() : sequence(0), expirationTime(0), master(), stakes(), proofid() {} Proof(uint64_t sequence_, int64_t expirationTime_, CPubKey master_, @@ -92,11 +95,13 @@ : sequence(sequence_), expirationTime(expirationTime_), master(std::move(master_)), stakes(std::move(stakes_)) { computeProofId(); + computeScore(); } SERIALIZE_METHODS(Proof, obj) { READWRITE(obj.sequence, obj.expirationTime, obj.master, obj.stakes); SER_READ(obj, obj.computeProofId()); + SER_READ(obj, obj.computeScore()); } static bool FromHex(Proof &proof, const std::string &hexProof, @@ -109,7 +114,7 @@ const ProofId &getId() const { return proofid; } const LimitedProofId &getLimitedId() const { return limitedProofId; } - 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 @@ -61,13 +61,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 {