Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13711216
D10032.id29768.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D10032.id29768.diff
View Options
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 {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 26, 11:00 (12 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5573345
Default Alt Text
D10032.id29768.diff (1 KB)
Attached To
D10032: [avalanche] Cache the peer score
Event Timeline
Log In to Comment