38 status, proof->getPayoutScript(), proof->getScore())
43 const CBlockIndex *pindex,
const std::vector<CScript> &payoutScripts) {
46 auto it =
view.find(prevblockhash);
47 if (it ==
view.end()) {
49 .emplace(prevblockhash, pindex->
nHeight, payoutScripts)
59 if (it ==
view.end()) {
71 if (it ==
view.end()) {
84 if (it ==
view.end()) {
96 if (it ==
view.end()) {
110 if (it ==
view.end()) {
115 if (it->isAccepted()) {
135 std::vector<CScript> &
payouts)
const {
139 auto [begin, end] =
view.equal_range(prevblockhash);
140 for (
auto it = begin; it != end; it++) {
141 if (it->isInWinnerSet()) {
149 return left->computeRewardRank() < right->computeRewardRank();
The block chain is a tree shaped structure starting with the genesis block at the root,...
BlockHash GetBlockHash() const
int nHeight
height of the entry in the chain. The genesis block has height 0
bool invalidate(const StakeContenderId &contenderId)
ManualWinnersSet manualWinners
bool accept(const StakeContenderId &contenderId)
Helpers to set avalanche state of a contender.
bool reject(const StakeContenderId &contenderId)
int getVoteStatus(const StakeContenderId &contenderId) const
Get contender acceptance state for avalanche voting.
bool setWinners(const CBlockIndex *pindex, const std::vector< CScript > &payoutScripts)
Set proof(s) that should be treated as winners (already finalized).
void cleanup(const int minHeight)
bool add(const CBlockIndex *pindex, const ProofRef &proof, uint8_t status=StakeContenderStatus::UNKNOWN)
Add a proof to consider in staking rewards pre-consensus.
bool finalize(const StakeContenderId &contenderId)
bool getWinners(const BlockHash &prevblockhash, std::vector< CScript > &payouts) const
Get payout scripts of the winning proofs.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
A BlockHash is a unqiue identifier for a block.
StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has ...