Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proof.h
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
class Proof { | class Proof { | ||||
uint64_t sequence; | uint64_t sequence; | ||||
int64_t expirationTime; | int64_t expirationTime; | ||||
CPubKey master; | CPubKey master; | ||||
std::vector<SignedStake> stakes; | std::vector<SignedStake> stakes; | ||||
LimitedProofId limitedProofId; | |||||
ProofId proofid; | ProofId proofid; | ||||
ProofId computeProofId() const; | void computeProofId(); | ||||
public: | public: | ||||
Proof() : sequence(0), expirationTime(0), master(), stakes(), proofid() {} | Proof() : sequence(0), expirationTime(0), master(), stakes(), proofid() {} | ||||
Proof(uint64_t sequence_, int64_t expirationTime_, CPubKey master_, | Proof(uint64_t sequence_, int64_t expirationTime_, CPubKey master_, | ||||
std::vector<SignedStake> stakes_) | std::vector<SignedStake> stakes_) | ||||
: sequence(sequence_), expirationTime(expirationTime_), | : sequence(sequence_), expirationTime(expirationTime_), | ||||
master(std::move(master_)), stakes(std::move(stakes_)), | master(std::move(master_)), stakes(std::move(stakes_)) { | ||||
proofid(computeProofId()) {} | computeProofId(); | ||||
} | |||||
SERIALIZE_METHODS(Proof, obj) { | SERIALIZE_METHODS(Proof, obj) { | ||||
READWRITE(obj.sequence, obj.expirationTime, obj.master, obj.stakes); | READWRITE(obj.sequence, obj.expirationTime, obj.master, obj.stakes); | ||||
SER_READ(obj, obj.proofid = obj.computeProofId()); | SER_READ(obj, obj.computeProofId()); | ||||
} | } | ||||
static bool FromHex(Proof &proof, const std::string &hexProof, | static bool FromHex(Proof &proof, const std::string &hexProof, | ||||
bilingual_str &errorOut); | bilingual_str &errorOut); | ||||
uint64_t getSequence() const { return sequence; } | uint64_t getSequence() const { return sequence; } | ||||
int64_t getExpirationTime() const { return expirationTime; } | int64_t getExpirationTime() const { return expirationTime; } | ||||
const CPubKey &getMaster() const { return master; } | const CPubKey &getMaster() const { return master; } | ||||
const std::vector<SignedStake> &getStakes() const { return stakes; } | const std::vector<SignedStake> &getStakes() const { return stakes; } | ||||
const ProofId &getId() const { return proofid; } | const ProofId &getId() const { return proofid; } | ||||
const LimitedProofId &getLimitedId() const { return limitedProofId; } | |||||
uint32_t getScore() const; | uint32_t getScore() const; | ||||
bool verify(ProofValidationState &state) const; | bool verify(ProofValidationState &state) const; | ||||
bool verify(ProofValidationState &state, const CCoinsView &view) const; | bool verify(ProofValidationState &state, const CCoinsView &view) const; | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROOF_H | #endif // BITCOIN_AVALANCHE_PROOF_H |