Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.cpp
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | bool Proof::FromHex(Proof &proof, const std::string &hexProof, | ||||
} catch (std::exception &e) { | } catch (std::exception &e) { | ||||
errorOut = strprintf(_("Proof has invalid format: %s"), e.what()); | errorOut = strprintf(_("Proof has invalid format: %s"), e.what()); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
ProofId Proof::computeIdFromLimitedId(const LimitedProofId &limitedId, | |||||
const CPubKey &master) { | |||||
CHashWriter ss(SER_GETHASH, 0); | |||||
ss << limitedId; | |||||
ss << master; | |||||
return ProofId(ss.GetHash()); | |||||
} | |||||
void Proof::computeProofId() { | void Proof::computeProofId() { | ||||
CHashWriter ss(SER_GETHASH, 0); | CHashWriter ss(SER_GETHASH, 0); | ||||
ss << sequence; | ss << sequence; | ||||
ss << expirationTime; | ss << expirationTime; | ||||
WriteCompactSize(ss, stakes.size()); | WriteCompactSize(ss, stakes.size()); | ||||
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 = computeIdFromLimitedId(limitedProofId, master); | |||||
CHashWriter ss2(SER_GETHASH, 0); | |||||
ss2 << limitedProofId; | |||||
ss2 << master; | |||||
proofid = ProofId(ss2.GetHash()); | |||||
} | } | ||||
uint32_t Proof::getScore() const { | uint32_t Proof::getScore() const { | ||||
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(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |