Bitcoin ABC 0.26.3
P2P Digital Currency
|
Cache to track stake contenders for recent blocks. More...
#include <stakecontendercache.h>
Public Member Functions | |
StakeContenderCache () | |
void | cleanup (const int minHeight) |
size_t | isEmpty () const |
For tests. | |
bool | add (const CBlockIndex *pindex, const ProofRef &proof, uint8_t status=StakeContenderStatus::UNKNOWN) |
Add a proof to consider in staking rewards pre-consensus. | |
bool | addWinner (const CBlockIndex *pindex, const CScript &payoutScript) |
Add a proof that should be treated as a winner (already finalized). | |
bool | accept (const StakeContenderId &contenderId) |
Helpers to set avalanche state of a contender. | |
bool | finalize (const StakeContenderId &contenderId) |
bool | reject (const StakeContenderId &contenderId) |
bool | invalidate (const StakeContenderId &contenderId) |
int | getVoteStatus (const StakeContenderId &contenderId) const |
Get contender acceptance state for avalanche voting. | |
bool | getWinners (const BlockHash &prevblockhash, std::vector< CScript > &payouts) const |
Get payout scripts of the winning proofs. | |
Private Types | |
using | ContenderSet = boost::multi_index_container< StakeContenderCacheEntry, bmi::indexed_by< bmi::hashed_unique< bmi::tag< by_stakecontenderid >, stakecontenderid_index, SaltedUint256Hasher >, bmi::hashed_non_unique< bmi::tag< by_prevblockhash >, bmi::member< StakeContenderCacheEntry, BlockHash, &StakeContenderCacheEntry::prevblockhash >, SaltedUint256Hasher >, bmi::ordered_non_unique< bmi::tag< by_blockheight >, bmi::member< StakeContenderCacheEntry, int, &StakeContenderCacheEntry::blockheight > > > > |
using | ManualWinnersSet = boost::multi_index_container< ManualWinners, bmi::indexed_by< bmi::hashed_unique< bmi::tag< by_prevblockhash >, bmi::member< ManualWinners, BlockHash, &ManualWinners::prevblockhash >, SaltedUint256Hasher >, bmi::ordered_unique< bmi::tag< by_blockheight >, bmi::member< ManualWinners, int, &ManualWinners::blockheight > > > > |
Private Attributes | |
ContenderSet | contenders |
ManualWinnersSet | manualWinners |
Cache to track stake contenders for recent blocks.
Definition at line 88 of file stakecontendercache.h.
|
private |
Definition at line 89 of file stakecontendercache.h.
|
private |
Definition at line 109 of file stakecontendercache.h.
|
inline |
Definition at line 125 of file stakecontendercache.h.
bool avalanche::StakeContenderCache::accept | ( | const StakeContenderId & | contenderId | ) |
Helpers to set avalanche state of a contender.
Definition at line 59 of file stakecontendercache.cpp.
bool avalanche::StakeContenderCache::add | ( | const CBlockIndex * | pindex, |
const ProofRef & | proof, | ||
uint8_t | status = StakeContenderStatus::UNKNOWN |
||
) |
Add a proof to consider in staking rewards pre-consensus.
Definition at line 34 of file stakecontendercache.cpp.
bool avalanche::StakeContenderCache::addWinner | ( | const CBlockIndex * | pindex, |
const CScript & | payoutScript | ||
) |
Add a proof that should be treated as a winner (already finalized).
This should only be used for manually added winners via RPC.
Definition at line 42 of file stakecontendercache.cpp.
Definition at line 9 of file stakecontendercache.cpp.
bool avalanche::StakeContenderCache::finalize | ( | const StakeContenderId & | contenderId | ) |
Definition at line 71 of file stakecontendercache.cpp.
int avalanche::StakeContenderCache::getVoteStatus | ( | const StakeContenderId & | contenderId | ) | const |
Get contender acceptance state for avalanche voting.
Returns 0 for accepted, 1 for rejected, and -1 for not in cache.
Definition at line 109 of file stakecontendercache.cpp.
bool avalanche::StakeContenderCache::getWinners | ( | const BlockHash & | prevblockhash, |
std::vector< CScript > & | payouts | ||
) | const |
Get payout scripts of the winning proofs.
Definition at line 137 of file stakecontendercache.cpp.
bool avalanche::StakeContenderCache::invalidate | ( | const StakeContenderId & | contenderId | ) |
Definition at line 96 of file stakecontendercache.cpp.
|
inline |
For tests.
Definition at line 132 of file stakecontendercache.h.
bool avalanche::StakeContenderCache::reject | ( | const StakeContenderId & | contenderId | ) |
Definition at line 84 of file stakecontendercache.cpp.
|
private |
Definition at line 107 of file stakecontendercache.h.
|
private |
Definition at line 122 of file stakecontendercache.h.