Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

#include <deterministicmns.h>

+ Collaboration diagram for CDeterministicMNList:

Public Types

typedef immer::map< uint256, CDeterministicMNCPtrMnMap
 
typedef immer::map< uint64_t, uint256MnInternalIdMap
 
typedef immer::map< uint256, std::pair< uint256, uint32_t > > MnUniquePropertyMap
 

Public Member Functions

 CDeterministicMNList ()
 
 CDeterministicMNList (const uint256 &_blockHash, int _height, uint32_t _totalRegisteredCount)
 
template<typename Stream , typename Operation >
void SerializationOpBase (Stream &s, Operation ser_action)
 
template<typename Stream >
void Serialize (Stream &s) const
 
template<typename Stream >
void Unserialize (Stream &s)
 
size_t GetAllMNsCount () const
 
size_t GetValidMNsCount () const
 
template<typename Callback >
void ForEachMN (bool onlyValid, Callback &&cb) const
 
const uint256GetBlockHash () const
 
void SetBlockHash (const uint256 &_blockHash)
 
int GetHeight () const
 
void SetHeight (int _height)
 
uint32_t GetTotalRegisteredCount () const
 
bool IsMNValid (const uint256 &proTxHash) const
 
bool IsMNPoSeBanned (const uint256 &proTxHash) const
 
bool IsMNValid (const CDeterministicMNCPtr &dmn) const
 
bool IsMNPoSeBanned (const CDeterministicMNCPtr &dmn) const
 
bool HasMN (const uint256 &proTxHash) const
 
bool HasMNByCollateral (const COutPoint &collateralOutpoint) const
 
bool HasValidMNByCollateral (const COutPoint &collateralOutpoint) const
 
CDeterministicMNCPtr GetMN (const uint256 &proTxHash) const
 
CDeterministicMNCPtr GetValidMN (const uint256 &proTxHash) const
 
CDeterministicMNCPtr GetMNByOperatorKey (const CBLSPublicKey &pubKey)
 
CDeterministicMNCPtr GetMNByCollateral (const COutPoint &collateralOutpoint) const
 
CDeterministicMNCPtr GetValidMNByCollateral (const COutPoint &collateralOutpoint) const
 
CDeterministicMNCPtr GetMNByService (const CService &service) const
 
CDeterministicMNCPtr GetMNByInternalId (uint64_t internalId) const
 
CDeterministicMNCPtr GetMNPayee () const
 
std::vector< CDeterministicMNCPtrGetProjectedMNPayees (int nCount) const
 Calculates the projected MN payees for the next count blocks. More...
 
std::vector< CDeterministicMNCPtrCalculateQuorum (size_t maxSize, const uint256 &modifier) const
 Calculate a quorum based on the modifier. More...
 
std::vector< std::pair< arith_uint256, CDeterministicMNCPtr > > CalculateScores (const uint256 &modifier) const
 
int CalcMaxPoSePenalty () const
 Calculates the maximum penalty which is allowed at the height of this MN list. More...
 
int CalcPenalty (int percent) const
 Returns a the given percentage from the max penalty for this MN list. More...
 
void PoSePunish (const uint256 &proTxHash, int penalty, bool debugLogs)
 Punishes a MN for misbehavior. More...
 
void PoSeDecrease (const uint256 &proTxHash)
 Decrease penalty score of MN by 1. More...
 
CDeterministicMNListDiff BuildDiff (const CDeterministicMNList &to) const
 
CSimplifiedMNListDiff BuildSimplifiedDiff (const CDeterministicMNList &to) const
 
CDeterministicMNList ApplyDiff (const CBlockIndex *pindex, const CDeterministicMNListDiff &diff) const
 
void AddMN (const CDeterministicMNCPtr &dmn, bool fBumpTotalCount=true)
 
void UpdateMN (const CDeterministicMNCPtr &oldDmn, const CDeterministicMNStateCPtr &pdmnState)
 
void UpdateMN (const uint256 &proTxHash, const CDeterministicMNStateCPtr &pdmnState)
 
void UpdateMN (const CDeterministicMNCPtr &oldDmn, const CDeterministicMNStateDiff &stateDiff)
 
void RemoveMN (const uint256 &proTxHash)
 
template<typename T >
bool HasUniqueProperty (const T &v) const
 
template<typename T >
CDeterministicMNCPtr GetUniquePropertyMN (const T &v) const
 

Private Member Functions

template<typename T >
void AddUniqueProperty (const CDeterministicMNCPtr &dmn, const T &v)
 
template<typename T >
void DeleteUniqueProperty (const CDeterministicMNCPtr &dmn, const T &oldValue)
 
template<typename T >
void UpdateUniqueProperty (const CDeterministicMNCPtr &dmn, const T &oldValue, const T &newValue)
 

Private Attributes

uint256 blockHash
 
int nHeight {-1}
 
uint32_t nTotalRegisteredCount {0}
 
MnMap mnMap
 
MnInternalIdMap mnInternalIdMap
 
MnUniquePropertyMap mnUniquePropertyMap
 

Detailed Description

Definition at line 288 of file deterministicmns.h.

Member Typedef Documentation

◆ MnInternalIdMap

Definition at line 292 of file deterministicmns.h.

◆ MnMap

◆ MnUniquePropertyMap

Definition at line 293 of file deterministicmns.h.

Constructor & Destructor Documentation

◆ CDeterministicMNList() [1/2]

CDeterministicMNList::CDeterministicMNList ( )
inline

Definition at line 307 of file deterministicmns.h.

◆ CDeterministicMNList() [2/2]

CDeterministicMNList::CDeterministicMNList ( const uint256 _blockHash,
int  _height,
uint32_t  _totalRegisteredCount 
)
inlineexplicit

Definition at line 308 of file deterministicmns.h.

Member Function Documentation

◆ AddMN()

◆ AddUniqueProperty()

template<typename T >
void CDeterministicMNList::AddUniqueProperty ( const CDeterministicMNCPtr dmn,
const T &  v 
)
inlineprivate

◆ ApplyDiff()

◆ BuildDiff()

◆ BuildSimplifiedDiff()

◆ CalcMaxPoSePenalty()

int CDeterministicMNList::CalcMaxPoSePenalty ( ) const

Calculates the maximum penalty which is allowed at the height of this MN list.

It is dynamic and might change for every block.

Returns

Definition at line 301 of file deterministicmns.cpp.

References GetAllMNsCount().

Referenced by CalcPenalty(), and PoSePunish().

◆ CalcPenalty()

int CDeterministicMNList::CalcPenalty ( int  percent) const

Returns a the given percentage from the max penalty for this MN list.

Always use this method to calculate the value later passed to PoSePunish. The percentage should be high enough to take per-block penalty decreasing for MNs into account. This means, if you want to accept 2 failures per payment cycle, you should choose a percentage that is higher then 50%, e.g. 66%.

Parameters
percent
Returns

Definition at line 309 of file deterministicmns.cpp.

References CalcMaxPoSePenalty().

Referenced by CDeterministicMNManager::HandleQuorumCommitment().

◆ CalculateQuorum()

std::vector< CDeterministicMNCPtr > CDeterministicMNList::CalculateQuorum ( size_t  maxSize,
const uint256 modifier 
) const

Calculate a quorum based on the modifier.

The resulting list is deterministically sorted by score

Parameters
maxSize
modifier
Returns

Definition at line 253 of file deterministicmns.cpp.

References CalculateScores().

◆ CalculateScores()

std::vector< std::pair< arith_uint256, CDeterministicMNCPtr > > CDeterministicMNList::CalculateScores ( const uint256 modifier) const

◆ DeleteUniqueProperty()

template<typename T >
void CDeterministicMNList::DeleteUniqueProperty ( const CDeterministicMNCPtr dmn,
const T &  oldValue 
)
inlineprivate

◆ ForEachMN()

template<typename Callback >
void CDeterministicMNList::ForEachMN ( bool  onlyValid,
Callback &&  cb 
) const
inline

◆ GetAllMNsCount()

◆ GetBlockHash()

const uint256& CDeterministicMNList::GetBlockHash ( ) const
inline

◆ GetHeight()

int CDeterministicMNList::GetHeight ( ) const
inline

◆ GetMN()

◆ GetMNByCollateral()

CDeterministicMNCPtr CDeterministicMNList::GetMNByCollateral ( const COutPoint collateralOutpoint) const

◆ GetMNByInternalId()

CDeterministicMNCPtr CDeterministicMNList::GetMNByInternalId ( uint64_t  internalId) const

◆ GetMNByOperatorKey()

CDeterministicMNCPtr CDeterministicMNList::GetMNByOperatorKey ( const CBLSPublicKey pubKey)

Definition at line 152 of file deterministicmns.cpp.

References mnMap.

Referenced by CActiveMasternodeManager::Init().

◆ GetMNByService()

CDeterministicMNCPtr CDeterministicMNList::GetMNByService ( const CService service) const

Definition at line 176 of file deterministicmns.cpp.

References GetUniquePropertyMN().

◆ GetMNPayee()

◆ GetProjectedMNPayees()

std::vector< CDeterministicMNCPtr > CDeterministicMNList::GetProjectedMNPayees ( int  nCount) const

Calculates the projected MN payees for the next count blocks.

The result is not guaranteed to be correct as PoSe banning might occur later

Parameters
count
Returns

Definition at line 232 of file deterministicmns.cpp.

References CompareByLastPaid(), ForEachMN(), and GetValidMNsCount().

◆ GetTotalRegisteredCount()

uint32_t CDeterministicMNList::GetTotalRegisteredCount ( ) const
inline

◆ GetUniquePropertyMN()

template<typename T >
CDeterministicMNCPtr CDeterministicMNList::GetUniquePropertyMN ( const T &  v) const
inline

◆ GetValidMN()

CDeterministicMNCPtr CDeterministicMNList::GetValidMN ( const uint256 proTxHash) const

Definition at line 143 of file deterministicmns.cpp.

References GetMN(), and IsMNValid().

◆ GetValidMNByCollateral()

CDeterministicMNCPtr CDeterministicMNList::GetValidMNByCollateral ( const COutPoint collateralOutpoint) const

Definition at line 167 of file deterministicmns.cpp.

References GetMNByCollateral(), and IsMNValid().

Referenced by HasValidMNByCollateral().

◆ GetValidMNsCount()

size_t CDeterministicMNList::GetValidMNsCount ( ) const
inline

◆ HasMN()

bool CDeterministicMNList::HasMN ( const uint256 proTxHash) const
inline

◆ HasMNByCollateral()

bool CDeterministicMNList::HasMNByCollateral ( const COutPoint collateralOutpoint) const
inline

Definition at line 406 of file deterministicmns.h.

References GetMNByCollateral().

◆ HasUniqueProperty()

template<typename T >
bool CDeterministicMNList::HasUniqueProperty ( const T &  v) const
inline

◆ HasValidMNByCollateral()

bool CDeterministicMNList::HasValidMNByCollateral ( const COutPoint collateralOutpoint) const
inline

Definition at line 410 of file deterministicmns.h.

References GetValidMNByCollateral().

◆ IsMNPoSeBanned() [1/2]

bool CDeterministicMNList::IsMNPoSeBanned ( const uint256 proTxHash) const

◆ IsMNPoSeBanned() [2/2]

bool CDeterministicMNList::IsMNPoSeBanned ( const CDeterministicMNCPtr dmn) const

Definition at line 127 of file deterministicmns.cpp.

References CDeterministicMNState::nPoSeBanHeight.

◆ IsMNValid() [1/2]

bool CDeterministicMNList::IsMNValid ( const uint256 proTxHash) const

◆ IsMNValid() [2/2]

bool CDeterministicMNList::IsMNValid ( const CDeterministicMNCPtr dmn) const

Definition at line 122 of file deterministicmns.cpp.

References IsMNPoSeBanned().

◆ PoSeDecrease()

void CDeterministicMNList::PoSeDecrease ( const uint256 proTxHash)

Decrease penalty score of MN by 1.

Only allowed on non-banned MNs.

Parameters
proTxHash

Definition at line 345 of file deterministicmns.cpp.

References GetMN(), strprintf, base_blob< BITS >::ToString(), and UpdateMN().

Referenced by CDeterministicMNManager::DecreasePoSePenalties().

◆ PoSePunish()

void CDeterministicMNList::PoSePunish ( const uint256 proTxHash,
int  penalty,
bool  debugLogs 
)

Punishes a MN for misbehavior.

If the resulting penalty score of the MN reaches the max penalty, it is banned. Penalty scores are only increased when the MN is not already banned, which means that after banning the penalty might appear lower then the current max penalty, while the MN is still banned.

Parameters
proTxHash
penalty

Definition at line 315 of file deterministicmns.cpp.

References CalcMaxPoSePenalty(), GetMN(), LogPrintf, nHeight, strprintf, base_blob< BITS >::ToString(), and UpdateMN().

Referenced by CDeterministicMNManager::HandleQuorumCommitment().

◆ RemoveMN()

◆ SerializationOpBase()

template<typename Stream , typename Operation >
void CDeterministicMNList::SerializationOpBase ( Stream &  s,
Operation  ser_action 
)
inline

Definition at line 316 of file deterministicmns.h.

References blockHash, nHeight, nTotalRegisteredCount, and READWRITE.

Referenced by Unserialize().

◆ Serialize()

template<typename Stream >
void CDeterministicMNList::Serialize ( Stream &  s) const
inline

◆ SetBlockHash()

void CDeterministicMNList::SetBlockHash ( const uint256 _blockHash)
inline

◆ SetHeight()

◆ Unserialize()

template<typename Stream >
void CDeterministicMNList::Unserialize ( Stream &  s)
inline

◆ UpdateMN() [1/3]

◆ UpdateMN() [2/3]

void CDeterministicMNList::UpdateMN ( const uint256 proTxHash,
const CDeterministicMNStateCPtr pdmnState 
)

◆ UpdateMN() [3/3]

void CDeterministicMNList::UpdateMN ( const CDeterministicMNCPtr oldDmn,
const CDeterministicMNStateDiff stateDiff 
)

Definition at line 501 of file deterministicmns.cpp.

References CDeterministicMNStateDiff::ApplyToState(), and UpdateMN().

◆ UpdateUniqueProperty()

template<typename T >
void CDeterministicMNList::UpdateUniqueProperty ( const CDeterministicMNCPtr dmn,
const T &  oldValue,
const T &  newValue 
)
inlineprivate

Definition at line 530 of file deterministicmns.h.

References AddUniqueProperty(), and DeleteUniqueProperty().

Referenced by UpdateMN().

Member Data Documentation

◆ blockHash

uint256 CDeterministicMNList::blockHash
private

◆ mnInternalIdMap

MnInternalIdMap CDeterministicMNList::mnInternalIdMap
private

Definition at line 300 of file deterministicmns.h.

Referenced by AddMN(), GetMNByInternalId(), RemoveMN(), and Unserialize().

◆ mnMap

◆ mnUniquePropertyMap

MnUniquePropertyMap CDeterministicMNList::mnUniquePropertyMap
private

◆ nHeight

int CDeterministicMNList::nHeight {-1}
private

Definition at line 297 of file deterministicmns.h.

Referenced by ApplyDiff(), GetHeight(), PoSePunish(), SerializationOpBase(), and SetHeight().

◆ nTotalRegisteredCount

uint32_t CDeterministicMNList::nTotalRegisteredCount {0}
private

Definition at line 298 of file deterministicmns.h.

Referenced by AddMN(), GetTotalRegisteredCount(), and SerializationOpBase().


The documentation for this class was generated from the following files:
Released under the MIT license