Bitcoin ABC 0.30.5
P2P Digital Currency
Public Member Functions | List of all members
avalanche::StakeContenderId Struct Reference

StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has strong guarantees that a newly finalizing block does not disrupt determining if the previous block had valid stake winners. More...

#include <stakecontender.h>

Inheritance diagram for avalanche::StakeContenderId:
[legend]
Collaboration diagram for avalanche::StakeContenderId:
[legend]

Public Member Functions

 StakeContenderId ()
 
 StakeContenderId (const uint256 &b)
 
 StakeContenderId (const BlockHash &prevblockhash, const ProofId &proofid)
 
double ComputeProofRewardRank (uint32_t proofScore)
 To make sure the selection is properly weighted according to the proof score, we normalize the contenderId to a number between 0 and 1, then take the logarithm and divide by the weight. More...
 
- Public Member Functions inherited from uint256
constexpr uint256 ()
 
constexpr uint256 (uint8_t v)
 
 uint256 (const std::vector< uint8_t > &vch)
 
- Public Member Functions inherited from base_blob< 256 >
constexpr base_blob ()
 
constexpr base_blob (uint8_t v)
 
 base_blob (const std::vector< uint8_t > &vch)
 
bool IsNull () const
 
void SetNull ()
 
int Compare (const base_blob &other) const
 
std::string GetHex () const
 
void SetHex (const char *psz)
 
void SetHex (const std::string &str)
 
std::string ToString () const
 
const uint8_t * data () const
 
uint8_t * data ()
 
uint8_t * begin ()
 
const uint8_t * begin () const
 
uint8_t * end ()
 
const uint8_t * end () const
 
unsigned int size () const
 
uint64_t GetUint64 (int pos) const
 
void Serialize (Stream &s) const
 
void Unserialize (Stream &s)
 

Additional Inherited Members

- Static Public Attributes inherited from uint256
static const uint256 ZERO
 
static const uint256 ONE
 
- Protected Attributes inherited from base_blob< 256 >
uint8_t m_data [WIDTH]
 
- Static Protected Attributes inherited from base_blob< 256 >
static constexpr int WIDTH
 

Detailed Description

StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has strong guarantees that a newly finalizing block does not disrupt determining if the previous block had valid stake winners.

Definition at line 25 of file stakecontender.h.

Constructor & Destructor Documentation

◆ StakeContenderId() [1/3]

avalanche::StakeContenderId::StakeContenderId ( )
inlineexplicit

Definition at line 26 of file stakecontender.h.

◆ StakeContenderId() [2/3]

avalanche::StakeContenderId::StakeContenderId ( const uint256 b)
inlineexplicit

Definition at line 27 of file stakecontender.h.

◆ StakeContenderId() [3/3]

avalanche::StakeContenderId::StakeContenderId ( const BlockHash prevblockhash,
const ProofId proofid 
)
inlineexplicit

Definition at line 28 of file stakecontender.h.

Member Function Documentation

◆ ComputeProofRewardRank()

double avalanche::StakeContenderId::ComputeProofRewardRank ( uint32_t  proofScore)
inline

To make sure the selection is properly weighted according to the proof score, we normalize the contenderId to a number between 0 and 1, then take the logarithm and divide by the weight.

Since it is scale-independent, we can simplify by removing constants and use base 2 logarithm. Inspired by: https://stackoverflow.com/a/30226926.

Definition at line 39 of file stakecontender.h.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this struct was generated from the following file: