Dash Core  0.12.2.1
P2P Digital Currency
CGovernanceObject Class Referenceabstract

#include <governance-classes.h>

+ Inheritance diagram for CGovernanceObject:

Public Types

typedef std::map< COutPoint, vote_rec_tvote_m_t
 
typedef vote_m_t::iterator vote_m_it
 
typedef vote_m_t::const_iterator vote_m_cit
 
typedef CacheMultiMap< COutPoint, vote_time_pair_tvote_mcache_t
 

Public Member Functions

virtual uint256 GetHash ()=0
 
 CGovernanceObject ()
 
 CGovernanceObject (uint256 nHashParentIn, int nRevisionIn, int64_t nTime, uint256 nCollateralHashIn, std::string strDataIn)
 
 CGovernanceObject (const CGovernanceObject &other)
 
void swap (CGovernanceObject &first, CGovernanceObject &second)
 
int64_t GetCreationTime () const
 
int64_t GetDeletionTime () const
 
int GetObjectType () const
 
const uint256GetCollateralHash () const
 
const CTxInGetMasternodeVin () const
 
bool IsSetCachedFunding () const
 
bool IsSetCachedValid () const
 
bool IsSetCachedDelete () const
 
bool IsSetCachedEndorsed () const
 
bool IsSetDirtyCache () const
 
bool IsSetExpired () const
 
void InvalidateVoteCache ()
 
CGovernanceObjectVoteFileGetVoteFile ()
 
void SetMasternodeVin (const COutPoint &outpoint)
 
bool Sign (CKey &keyMasternode, CPubKey &pubKeyMasternode)
 
bool CheckSignature (CPubKey &pubKeyMasternode)
 
std::string GetSignatureMessage () const
 
bool IsValidLocally (std::string &strError, bool fCheckCollateral)
 
bool IsValidLocally (std::string &strError, bool &fMissingMasternode, bool &fMissingConfirmations, bool fCheckCollateral)
 
bool IsCollateralValid (std::string &strError, bool &fMissingConfirmations)
 Check the collateral transaction for the budget proposal/finalized budget. More...
 
void UpdateLocalValidity ()
 
void UpdateSentinelVariables ()
 
int GetObjectSubtype ()
 
CAmount GetMinCollateralFee ()
 
UniValue GetJSONObject ()
 
void Relay (CConnman &connman)
 
uint256 GetHash () const
 
int CountMatchingVotes (vote_signal_enum_t eVoteSignalIn, vote_outcome_enum_t eVoteOutcomeIn) const
 
int GetAbsoluteYesCount (vote_signal_enum_t eVoteSignalIn) const
 
int GetAbsoluteNoCount (vote_signal_enum_t eVoteSignalIn) const
 
int GetYesCount (vote_signal_enum_t eVoteSignalIn) const
 
int GetNoCount (vote_signal_enum_t eVoteSignalIn) const
 
int GetAbstainCount (vote_signal_enum_t eVoteSignalIn) const
 
bool GetCurrentMNVotes (const COutPoint &mnCollateralOutpoint, vote_rec_t &voteRecord)
 
std::string GetDataAsHex ()
 
std::string GetDataAsString ()
 
template<typename Stream , typename Operation >
void SerializationOp (Stream &s, Operation ser_action, int nType, int nVersion)
 
CGovernanceObjectoperator= (CGovernanceObject from)
 

Public Attributes

 ADD_SERIALIZE_METHODS
 

Private Member Functions

void LoadData ()
 
void GetData (UniValue &objResult)
 
bool ProcessVote (CNode *pfrom, const CGovernanceVote &vote, CGovernanceException &exception, CConnman &connman)
 
void ClearMasternodeVotes ()
 Called when MN's which have voted on this object have been removed. More...
 
void CheckOrphanVotes (CConnman &connman)
 

Private Attributes

int nLevel
 
std::string strCategory
 
int nStatusID
 
std::string strStatusMessage
 
uint64_t nTimeValueOverrideCached
 
CCriticalSection cs
 critical section to protect the inner data structures More...
 
int nObjectType
 Object typecode. More...
 
uint256 nHashParent
 parent object, 0 is root More...
 
int nRevision
 object revision in the system More...
 
int64_t nTime
 time this object was created More...
 
int64_t nDeletionTime
 time this object was marked for deletion More...
 
uint256 nCollateralHash
 fee-tx More...
 
std::string strData
 Data field - can be used for anything. More...
 
CTxIn vinMasternode
 Masternode info for signed objects. More...
 
std::vector< unsigned char > vchSig
 
bool fCachedLocalValidity
 is valid by blockchain More...
 
std::string strLocalValidityError
 
bool fCachedFunding
 true == minimum network support has been reached for this object to be funded (doesn't mean it will for sure though) More...
 
bool fCachedValid
 true == minimum network has been reached flagging this object as a valid and understood goverance object (e.g, the serialized data is correct format, etc) More...
 
bool fCachedDelete
 true == minimum network support has been reached saying this object should be deleted from the system entirely More...
 
bool fCachedEndorsed
 
bool fDirtyCache
 object was updated and cached values should be updated soon More...
 
bool fExpired
 Object is no longer of interest. More...
 
bool fUnparsable
 Failed to parse object data. More...
 
vote_m_t mapCurrentMNVotes
 
vote_mcache_t mapOrphanVotes
 Limited map of votes orphaned by MN. More...
 
CGovernanceObjectVoteFile fileVotes
 

Friends

class CGovernanceManager
 
class CGovernanceTriggerManager
 

Detailed Description

Governance Object

Definition at line 113 of file governance-classes.h.

Member Typedef Documentation

◆ vote_m_cit

typedef vote_m_t::const_iterator CGovernanceObject::vote_m_cit

Definition at line 123 of file governance-object.h.

◆ vote_m_it

typedef vote_m_t::iterator CGovernanceObject::vote_m_it

Definition at line 121 of file governance-object.h.

◆ vote_m_t

Definition at line 119 of file governance-object.h.

◆ vote_mcache_t

Constructor & Destructor Documentation

◆ CGovernanceObject() [1/3]

CGovernanceObject::CGovernanceObject ( )

Definition at line 17 of file governance-object.cpp.

◆ CGovernanceObject() [2/3]

CGovernanceObject::CGovernanceObject ( uint256  nHashParentIn,
int  nRevisionIn,
int64_t  nTime,
uint256  nCollateralHashIn,
std::string  strDataIn 
)

Definition at line 45 of file governance-object.cpp.

◆ CGovernanceObject() [3/3]

CGovernanceObject::CGovernanceObject ( const CGovernanceObject other)

Definition at line 73 of file governance-object.cpp.

Member Function Documentation

◆ CheckOrphanVotes()

void CGovernanceObject::CheckOrphanVotes ( CConnman connman)
private

Definition at line 719 of file governance-object.cpp.

◆ CheckSignature()

bool CGovernanceObject::CheckSignature ( CPubKey pubKeyMasternode)

Definition at line 255 of file governance-object.cpp.

Referenced by IsValidLocally().

◆ ClearMasternodeVotes()

void CGovernanceObject::ClearMasternodeVotes ( )
private

Called when MN's which have voted on this object have been removed.

Definition at line 199 of file governance-object.cpp.

◆ CountMatchingVotes()

int CGovernanceObject::CountMatchingVotes ( vote_signal_enum_t  eVoteSignalIn,
vote_outcome_enum_t  eVoteOutcomeIn 
) const

Definition at line 596 of file governance-object.cpp.

Referenced by GetAbstainCount(), GetNoCount(), and GetYesCount().

◆ GetAbsoluteNoCount()

int CGovernanceObject::GetAbsoluteNoCount ( vote_signal_enum_t  eVoteSignalIn) const

Definition at line 622 of file governance-object.cpp.

Referenced by UpdateSentinelVariables().

◆ GetAbsoluteYesCount()

int CGovernanceObject::GetAbsoluteYesCount ( vote_signal_enum_t  eVoteSignalIn) const

Get specific vote counts for each outcome (funding, validity, etc)

Definition at line 617 of file governance-object.cpp.

Referenced by CSuperblockManager::GetBestSuperblock(), gobject(), and UpdateSentinelVariables().

◆ GetAbstainCount()

int CGovernanceObject::GetAbstainCount ( vote_signal_enum_t  eVoteSignalIn) const

Definition at line 637 of file governance-object.cpp.

Referenced by gobject().

◆ GetCollateralHash()

const uint256& CGovernanceObject::GetCollateralHash ( ) const
inline

Definition at line 215 of file governance-object.h.

Referenced by gobject().

◆ GetCreationTime()

◆ GetCurrentMNVotes()

bool CGovernanceObject::GetCurrentMNVotes ( const COutPoint mnCollateralOutpoint,
vote_rec_t voteRecord 
)

Definition at line 642 of file governance-object.cpp.

Referenced by CGovernanceManager::GetCurrentVotes().

◆ GetData()

void CGovernanceObject::GetData ( UniValue objResult)
private

GetData - Example usage:

Decode governance object data into UniValue(VOBJ)

Definition at line 376 of file governance-object.cpp.

Referenced by GetJSONObject(), and LoadData().

◆ GetDataAsHex()

std::string CGovernanceObject::GetDataAsHex ( )

GetData - As

Definition at line 390 of file governance-object.cpp.

Referenced by gobject(), and CSuperblock::IsValid().

◆ GetDataAsString()

◆ GetDeletionTime()

int64_t CGovernanceObject::GetDeletionTime ( ) const
inline

Definition at line 207 of file governance-object.h.

Referenced by CGovernanceManager::UpdateCachesAndClean().

◆ GetHash() [1/2]

◆ GetHash() [2/2]

uint256 CGovernanceObject::GetHash ( ) const

Definition at line 279 of file governance-object.cpp.

◆ GetJSONObject()

UniValue CGovernanceObject::GetJSONObject ( )

Return the actual object from the strData JSON structure.

Returns an empty object on error.

Definition at line 303 of file governance-object.cpp.

Referenced by LoadData().

◆ GetMasternodeVin()

const CTxIn& CGovernanceObject::GetMasternodeVin ( ) const
inline

◆ GetMinCollateralFee()

CAmount CGovernanceObject::GetMinCollateralFee ( )

Definition at line 491 of file governance-object.cpp.

Referenced by gobject(), and IsCollateralValid().

◆ GetNoCount()

int CGovernanceObject::GetNoCount ( vote_signal_enum_t  eVoteSignalIn) const

Definition at line 632 of file governance-object.cpp.

Referenced by GetAbsoluteNoCount(), GetAbsoluteYesCount(), and gobject().

◆ GetObjectSubtype()

int CGovernanceObject::GetObjectSubtype ( )

Definition at line 270 of file governance-object.cpp.

◆ GetObjectType()

◆ GetSignatureMessage()

std::string CGovernanceObject::GetSignatureMessage ( ) const

Definition at line 213 of file governance-object.cpp.

Referenced by CheckSignature(), and Sign().

◆ GetVoteFile()

◆ GetYesCount()

int CGovernanceObject::GetYesCount ( vote_signal_enum_t  eVoteSignalIn) const

Definition at line 627 of file governance-object.cpp.

Referenced by GetAbsoluteNoCount(), GetAbsoluteYesCount(), and gobject().

◆ InvalidateVoteCache()

void CGovernanceObject::InvalidateVoteCache ( )
inline

Definition at line 247 of file governance-object.h.

◆ IsCollateralValid()

bool CGovernanceObject::IsCollateralValid ( std::string &  strError,
bool &  fMissingConfirmations 
)

Check the collateral transaction for the budget proposal/finalized budget.

Definition at line 502 of file governance-object.cpp.

Referenced by CGovernanceManager::CheckPostponedObjects(), and IsValidLocally().

◆ IsSetCachedDelete()

bool CGovernanceObject::IsSetCachedDelete ( ) const
inline

◆ IsSetCachedEndorsed()

bool CGovernanceObject::IsSetCachedEndorsed ( ) const
inline

Definition at line 235 of file governance-object.h.

Referenced by gobject().

◆ IsSetCachedFunding()

bool CGovernanceObject::IsSetCachedFunding ( ) const
inline

Definition at line 223 of file governance-object.h.

Referenced by gobject(), and CSuperblockManager::IsSuperblockTriggered().

◆ IsSetCachedValid()

bool CGovernanceObject::IsSetCachedValid ( ) const
inline

Definition at line 227 of file governance-object.h.

Referenced by gobject().

◆ IsSetDirtyCache()

bool CGovernanceObject::IsSetDirtyCache ( ) const
inline

Definition at line 239 of file governance-object.h.

Referenced by CGovernanceManager::UpdateCachesAndClean().

◆ IsSetExpired()

bool CGovernanceObject::IsSetExpired ( ) const
inline

◆ IsValidLocally() [1/2]

bool CGovernanceObject::IsValidLocally ( std::string &  strError,
bool  fCheckCollateral 
)

◆ IsValidLocally() [2/2]

bool CGovernanceObject::IsValidLocally ( std::string &  strError,
bool &  fMissingMasternode,
bool &  fMissingConfirmations,
bool  fCheckCollateral 
)

Definition at line 419 of file governance-object.cpp.

◆ LoadData()

void CGovernanceObject::LoadData ( )
private

LoadData

Attempt to load data from strData

Definition at line 328 of file governance-object.cpp.

Referenced by CGovernanceObject().

◆ operator=()

CGovernanceObject& CGovernanceObject::operator= ( CGovernanceObject  from)
inline

Definition at line 333 of file governance-object.h.

◆ ProcessVote()

bool CGovernanceObject::ProcessVote ( CNode pfrom,
const CGovernanceVote vote,
CGovernanceException exception,
CConnman connman 
)
private

◆ Relay()

void CGovernanceObject::Relay ( CConnman connman)

◆ SerializationOp()

template<typename Stream , typename Operation >
void CGovernanceObject::SerializationOp ( Stream &  s,
Operation  ser_action,
int  nType,
int  nVersion 
)
inline

Definition at line 308 of file governance-object.h.

◆ SetMasternodeVin()

void CGovernanceObject::SetMasternodeVin ( const COutPoint outpoint)

Definition at line 226 of file governance-object.cpp.

Referenced by gobject().

◆ Sign()

bool CGovernanceObject::Sign ( CKey keyMasternode,
CPubKey pubKeyMasternode 
)

Definition at line 231 of file governance-object.cpp.

Referenced by gobject().

◆ swap()

void CGovernanceObject::swap ( CGovernanceObject first,
CGovernanceObject second 
)

Definition at line 695 of file governance-object.cpp.

Referenced by operator=().

◆ UpdateLocalValidity()

void CGovernanceObject::UpdateLocalValidity ( )

Definition at line 403 of file governance-object.cpp.

Referenced by CGovernanceManager::UpdateCachesAndClean().

◆ UpdateSentinelVariables()

void CGovernanceObject::UpdateSentinelVariables ( )

Friends And Related Function Documentation

◆ CGovernanceManager

friend class CGovernanceManager
friend

Definition at line 114 of file governance-object.h.

◆ CGovernanceTriggerManager

friend class CGovernanceTriggerManager
friend

Definition at line 116 of file governance-object.h.

Member Data Documentation

◆ ADD_SERIALIZE_METHODS

CGovernanceObject::ADD_SERIALIZE_METHODS

Definition at line 305 of file governance-object.h.

◆ cs

CCriticalSection CGovernanceObject::cs
mutableprivate

critical section to protect the inner data structures

Definition at line 129 of file governance-object.h.

Referenced by CheckSignature(), GetSignatureMessage(), and Sign().

◆ fCachedDelete

bool CGovernanceObject::fCachedDelete
private

true == minimum network support has been reached saying this object should be deleted from the system entirely

Definition at line 169 of file governance-object.h.

Referenced by IsSetCachedDelete(), swap(), and UpdateSentinelVariables().

◆ fCachedEndorsed

bool CGovernanceObject::fCachedEndorsed
private

true == minimum network support has been reached flagging this object as endorsed by an elected representative body (e.g. business review board / technecial review board /etc)

Definition at line 174 of file governance-object.h.

Referenced by IsSetCachedEndorsed(), swap(), and UpdateSentinelVariables().

◆ fCachedFunding

bool CGovernanceObject::fCachedFunding
private

true == minimum network support has been reached for this object to be funded (doesn't mean it will for sure though)

Definition at line 163 of file governance-object.h.

Referenced by IsSetCachedFunding(), swap(), and UpdateSentinelVariables().

◆ fCachedLocalValidity

bool CGovernanceObject::fCachedLocalValidity
private

is valid by blockchain

Definition at line 157 of file governance-object.h.

Referenced by UpdateLocalValidity().

◆ fCachedValid

bool CGovernanceObject::fCachedValid
private

true == minimum network has been reached flagging this object as a valid and understood goverance object (e.g, the serialized data is correct format, etc)

Definition at line 166 of file governance-object.h.

Referenced by IsSetCachedValid(), swap(), and UpdateSentinelVariables().

◆ fDirtyCache

bool CGovernanceObject::fDirtyCache
private

object was updated and cached values should be updated soon

Definition at line 177 of file governance-object.h.

Referenced by InvalidateVoteCache(), IsSetDirtyCache(), ProcessVote(), swap(), and UpdateSentinelVariables().

◆ fExpired

bool CGovernanceObject::fExpired
private

Object is no longer of interest.

Definition at line 180 of file governance-object.h.

Referenced by CGovernanceTriggerManager::CleanAndRemove(), IsSetExpired(), SerializationOp(), and swap().

◆ fileVotes

CGovernanceObjectVoteFile CGovernanceObject::fileVotes
private

◆ fUnparsable

bool CGovernanceObject::fUnparsable
private

Failed to parse object data.

Definition at line 183 of file governance-object.h.

Referenced by IsValidLocally(), and LoadData().

◆ mapCurrentMNVotes

vote_m_t CGovernanceObject::mapCurrentMNVotes
private

◆ mapOrphanVotes

vote_mcache_t CGovernanceObject::mapOrphanVotes
private

Limited map of votes orphaned by MN.

Definition at line 188 of file governance-object.h.

Referenced by CheckOrphanVotes(), and ProcessVote().

◆ nCollateralHash

uint256 CGovernanceObject::nCollateralHash
private

◆ nDeletionTime

int64_t CGovernanceObject::nDeletionTime
private

time this object was marked for deletion

Definition at line 144 of file governance-object.h.

Referenced by CGovernanceTriggerManager::CleanAndRemove(), GetDeletionTime(), SerializationOp(), swap(), and UpdateSentinelVariables().

◆ nHashParent

uint256 CGovernanceObject::nHashParent
private

parent object, 0 is root

Definition at line 135 of file governance-object.h.

Referenced by GetHash(), GetSignatureMessage(), SerializationOp(), and swap().

◆ nLevel

int CGovernanceObject::nLevel
private

Definition at line 117 of file governance-classes.h.

◆ nObjectType

◆ nRevision

int CGovernanceObject::nRevision
private

object revision in the system

Definition at line 138 of file governance-object.h.

Referenced by GetHash(), GetSignatureMessage(), SerializationOp(), and swap().

◆ nStatusID

int CGovernanceObject::nStatusID
private

Definition at line 121 of file governance-classes.h.

◆ nTime

int64_t CGovernanceObject::nTime
private

◆ nTimeValueOverrideCached

uint64_t CGovernanceObject::nTimeValueOverrideCached
private

Definition at line 125 of file governance-classes.h.

◆ strCategory

std::string CGovernanceObject::strCategory
private

Definition at line 118 of file governance-classes.h.

◆ strData

std::string CGovernanceObject::strData
private

Data field - can be used for anything.

Definition at line 150 of file governance-object.h.

Referenced by GetDataAsHex(), GetDataAsString(), GetHash(), GetJSONObject(), GetSignatureMessage(), LoadData(), SerializationOp(), and swap().

◆ strLocalValidityError

std::string CGovernanceObject::strLocalValidityError
private

Definition at line 158 of file governance-object.h.

Referenced by UpdateLocalValidity().

◆ strStatusMessage

std::string CGovernanceObject::strStatusMessage
private

Definition at line 122 of file governance-classes.h.

◆ vchSig

std::vector<unsigned char> CGovernanceObject::vchSig
private

Definition at line 154 of file governance-object.h.

Referenced by CheckSignature(), GetHash(), SerializationOp(), and Sign().

◆ vinMasternode

CTxIn CGovernanceObject::vinMasternode
private

Masternode info for signed objects.

Definition at line 153 of file governance-object.h.

Referenced by GetHash(), GetMasternodeVin(), GetSignatureMessage(), IsValidLocally(), SerializationOp(), SetMasternodeVin(), and Sign().


The documentation for this class was generated from the following files: