![]() |
PIVX Core
5.6.99
P2P Digital Currency
|
#include <deterministicmns.h>
Public Types | |
| typedef immer::map< uint256, CDeterministicMNCPtr > | MnMap |
| typedef immer::map< uint64_t, uint256 > | MnInternalIdMap |
| 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 > | |
| 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 uint256 & | GetBlockHash () const |
| int | GetHeight () const |
| uint32_t | GetTotalRegisteredCount () const |
| void | SetHeight (int _height) |
| void | SetBlockHash (const uint256 &_blockHash) |
| 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< CDeterministicMNCPtr > | GetProjectedMNPayees (unsigned int nCount) const |
| Calculates the projected MN payees for the next count blocks. More... | |
| std::vector< CDeterministicMNCPtr > | CalculateQuorum (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 |
| 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 |
Definition at line 265 of file deterministicmns.h.
| typedef immer::map<uint64_t, uint256> CDeterministicMNList::MnInternalIdMap |
Definition at line 269 of file deterministicmns.h.
| typedef immer::map<uint256, CDeterministicMNCPtr> CDeterministicMNList::MnMap |
Definition at line 268 of file deterministicmns.h.
| typedef immer::map<uint256, std::pair<uint256, uint32_t> > CDeterministicMNList::MnUniquePropertyMap |
Definition at line 270 of file deterministicmns.h.
|
inline |
Definition at line 284 of file deterministicmns.h.
|
inlineexplicit |
Definition at line 285 of file deterministicmns.h.
| void CDeterministicMNList::AddMN | ( | const CDeterministicMNCPtr & | dmn, |
| bool | fBumpTotalCount = true |
||
| ) |
Definition at line 377 of file deterministicmns.cpp.
|
inlineprivate |
Definition at line 451 of file deterministicmns.h.
| CDeterministicMNList CDeterministicMNList::ApplyDiff | ( | const CBlockIndex * | pindex, |
| const CDeterministicMNListDiff & | diff | ||
| ) | const |
| CDeterministicMNListDiff CDeterministicMNList::BuildDiff | ( | const CDeterministicMNList & | to | ) | const |
Definition at line 322 of file deterministicmns.cpp.
| 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.
Definition at line 265 of file deterministicmns.cpp.
| 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%.
| percent |
Definition at line 273 of file deterministicmns.cpp.
| 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
| maxSize | |
| modifier |
Definition at line 217 of file deterministicmns.cpp.
| std::vector< std::pair< arith_uint256, CDeterministicMNCPtr > > CDeterministicMNList::CalculateScores | ( | const uint256 & | modifier | ) | const |
Definition at line 239 of file deterministicmns.cpp.
|
inlineprivate |
Definition at line 466 of file deterministicmns.h.
|
inline |
|
inline |
|
inline |
|
inline |
| CDeterministicMNCPtr CDeterministicMNList::GetMN | ( | const uint256 & | proTxHash | ) | const |
| CDeterministicMNCPtr CDeterministicMNList::GetMNByCollateral | ( | const COutPoint & | collateralOutpoint | ) | const |
Definition at line 126 of file deterministicmns.cpp.
| CDeterministicMNCPtr CDeterministicMNList::GetMNByInternalId | ( | uint64_t | internalId | ) | const |
Definition at line 145 of file deterministicmns.cpp.
| CDeterministicMNCPtr CDeterministicMNList::GetMNByOperatorKey | ( | const CBLSPublicKey & | pubKey | ) |
Definition at line 116 of file deterministicmns.cpp.
| CDeterministicMNCPtr CDeterministicMNList::GetMNByService | ( | const CService & | service | ) | const |
| CDeterministicMNCPtr CDeterministicMNList::GetMNPayee | ( | ) | const |
Definition at line 180 of file deterministicmns.cpp.
| std::vector< CDeterministicMNCPtr > CDeterministicMNList::GetProjectedMNPayees | ( | unsigned 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
| count |
Definition at line 196 of file deterministicmns.cpp.
|
inline |
Definition at line 350 of file deterministicmns.h.
|
inline |
Definition at line 440 of file deterministicmns.h.
| CDeterministicMNCPtr CDeterministicMNList::GetValidMN | ( | const uint256 & | proTxHash | ) | const |
| CDeterministicMNCPtr CDeterministicMNList::GetValidMNByCollateral | ( | const COutPoint & | collateralOutpoint | ) | const |
Definition at line 131 of file deterministicmns.cpp.
|
inline |
|
inline |
Definition at line 354 of file deterministicmns.h.
|
inline |
|
inline |
Definition at line 435 of file deterministicmns.h.
|
inline |
| void CDeterministicMNList::PoSeDecrease | ( | const uint256 & | proTxHash | ) |
Decrease penalty score of MN by 1.
Only allowed on non-banned MNs.
| proTxHash |
Definition at line 309 of file deterministicmns.cpp.
| 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.
| proTxHash | |
| penalty |
Definition at line 279 of file deterministicmns.cpp.
| void CDeterministicMNList::RemoveMN | ( | const uint256 & | proTxHash | ) |
Definition at line 445 of file deterministicmns.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
| void CDeterministicMNList::UpdateMN | ( | const CDeterministicMNCPtr & | oldDmn, |
| const CDeterministicMNStateCPtr & | pdmnState | ||
| ) |
Definition at line 409 of file deterministicmns.cpp.
| void CDeterministicMNList::UpdateMN | ( | const CDeterministicMNCPtr & | oldDmn, |
| const CDeterministicMNStateDiff & | stateDiff | ||
| ) |
| void CDeterministicMNList::UpdateMN | ( | const uint256 & | proTxHash, |
| const CDeterministicMNStateCPtr & | pdmnState | ||
| ) |
|
inlineprivate |
Definition at line 481 of file deterministicmns.h.
|
private |
Definition at line 273 of file deterministicmns.h.
|
private |
Definition at line 277 of file deterministicmns.h.
|
private |
Definition at line 276 of file deterministicmns.h.
|
private |
Definition at line 281 of file deterministicmns.h.
|
private |
Definition at line 274 of file deterministicmns.h.
|
private |
Definition at line 275 of file deterministicmns.h.