Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/proofbuilder.h
Show All 23 Lines | struct StakeSigner { | ||||
CKey key; | CKey key; | ||||
StakeSigner(Stake stake_, CKey key_) | StakeSigner(Stake stake_, CKey key_) | ||||
: stake(std::move(stake_)), key(std::move(key_)) {} | : stake(std::move(stake_)), key(std::move(key_)) {} | ||||
SignedStake sign(const ProofId &proofid); | SignedStake sign(const ProofId &proofid); | ||||
}; | }; | ||||
std::vector<StakeSigner> stakes; | struct StakeSignerComparator { | ||||
bool operator()(const StakeSigner &lhs, const StakeSigner &rhs) const { | |||||
return lhs.stake.getId() < rhs.stake.getId(); | |||||
} | |||||
}; | |||||
std::set<StakeSigner, StakeSignerComparator> stakes; | |||||
public: | public: | ||||
ProofBuilder(uint64_t sequence_, int64_t expirationTime_, CPubKey master_) | ProofBuilder(uint64_t sequence_, int64_t expirationTime_, CPubKey master_) | ||||
: sequence(sequence_), expirationTime(expirationTime_), | : sequence(sequence_), expirationTime(expirationTime_), | ||||
master(std::move(master_)) {} | master(std::move(master_)) {} | ||||
bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, | bool addUTXO(COutPoint utxo, Amount amount, uint32_t height, | ||||
bool is_coinbase, CKey key); | bool is_coinbase, CKey key); | ||||
Proof build(); | Proof build(); | ||||
/** | /** | ||||
* Builds a randomized (and therefore invalid) Proof. | * Builds a randomized (and therefore invalid) Proof. | ||||
* Useful for tests. | * Useful for tests. | ||||
*/ | */ | ||||
static Proof buildRandom(uint32_t score); | static Proof buildRandom(uint32_t score); | ||||
private: | private: | ||||
ProofId getProofId(); | ProofId getProofId() const; | ||||
friend struct TestProofBuilder; | friend struct TestProofBuilder; | ||||
}; | }; | ||||
} // namespace avalanche | } // namespace avalanche | ||||
#endif // BITCOIN_AVALANCHE_PROOFBUILDER_H | #endif // BITCOIN_AVALANCHE_PROOFBUILDER_H |