Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

#include <governance.h>

+ Collaboration diagram for CGovernanceManager:

Classes

struct  last_object_rec
 
class  ScopedLockBool
 

Public Types

typedef std::map< uint256, CGovernanceObjectobject_m_t
 
typedef object_m_t::iterator object_m_it
 
typedef object_m_t::const_iterator object_m_cit
 
typedef CacheMap< uint256, CGovernanceObject * > object_ref_cm_t
 
typedef std::map< uint256, CGovernanceVotevote_m_t
 
typedef vote_m_t::iterator vote_m_it
 
typedef vote_m_t::const_iterator vote_m_cit
 
typedef CacheMap< uint256, CGovernanceVotevote_cm_t
 
typedef CacheMultiMap< uint256, vote_time_pair_tvote_cmm_t
 
typedef object_m_t::size_type size_type
 
typedef std::map< COutPoint, last_object_rectxout_m_t
 
typedef txout_m_t::iterator txout_m_it
 
typedef std::set< uint256hash_s_t
 
typedef hash_s_t::iterator hash_s_it
 
typedef hash_s_t::const_iterator hash_s_cit
 
typedef std::map< uint256, object_info_pair_tobject_info_m_t
 
typedef object_info_m_t::iterator object_info_m_it
 
typedef std::map< uint256, int64_t > hash_time_m_t
 
typedef hash_time_m_t::iterator hash_time_m_it
 

Public Member Functions

 CGovernanceManager ()
 
virtual ~CGovernanceManager ()
 
bool ConfirmInventoryRequest (const CInv &inv)
 This is called by AlreadyHave in net_processing.cpp as part of the inventory retrieval process. More...
 
void SyncSingleObjVotes (CNode *pnode, const uint256 &nProp, const CBloomFilter &filter, CConnman &connman)
 
void SyncObjects (CNode *pnode, CConnman &connman) const
 
void ProcessMessage (CNode *pfrom, const std::string &strCommand, CDataStream &vRecv, CConnman &connman)
 
void DoMaintenance (CConnman &connman)
 
CGovernanceObjectFindGovernanceObject (const uint256 &nHash)
 
std::vector< CGovernanceVoteGetCurrentVotes (const uint256 &nParentHash, const COutPoint &mnCollateralOutpointFilter) const
 
std::vector< const CGovernanceObject * > GetAllNewerThan (int64_t nMoreThanTime) const
 
void AddGovernanceObject (CGovernanceObject &govobj, CConnman &connman, CNode *pfrom=nullptr)
 
void UpdateCachesAndClean ()
 
void CheckAndRemove ()
 
void Clear ()
 
std::string ToString () const
 
UniValue ToJson () const
 
template<typename Stream , typename Operation >
void SerializationOp (Stream &s, Operation ser_action)
 
void UpdatedBlockTip (const CBlockIndex *pindex, CConnman &connman)
 
int64_t GetLastDiffTime () const
 
void UpdateLastDiffTime (int64_t nTimeIn)
 
int GetCachedBlockHeight () const
 
bool HaveObjectForHash (const uint256 &nHash) const
 
bool HaveVoteForHash (const uint256 &nHash) const
 
int GetVoteCount () const
 
bool SerializeObjectForHash (const uint256 &nHash, CDataStream &ss) const
 
bool SerializeVoteForHash (const uint256 &nHash, CDataStream &ss) const
 
void AddPostponedObject (const CGovernanceObject &govobj)
 
void MasternodeRateUpdate (const CGovernanceObject &govobj)
 
bool MasternodeRateCheck (const CGovernanceObject &govobj, bool fUpdateFailStatus=false)
 
bool MasternodeRateCheck (const CGovernanceObject &govobj, bool fUpdateFailStatus, bool fForce, bool &fRateCheckBypassed)
 
bool ProcessVoteAndRelay (const CGovernanceVote &vote, CGovernanceException &exception, CConnman &connman)
 
void CheckPostponedObjects (CConnman &connman)
 
bool AreRateChecksEnabled () const
 
void InitOnLoad ()
 
int RequestGovernanceObjectVotes (CNode *pnode, CConnman &connman)
 
int RequestGovernanceObjectVotes (const std::vector< CNode *> &vNodesCopy, CConnman &connman)
 

Public Attributes

CCriticalSection cs
 
 ADD_SERIALIZE_METHODS
 

Private Member Functions

void RequestGovernanceObject (CNode *pfrom, const uint256 &nHash, CConnman &connman, bool fUseFilter=false)
 
void AddInvalidVote (const CGovernanceVote &vote)
 
bool ProcessVote (CNode *pfrom, const CGovernanceVote &vote, CGovernanceException &exception, CConnman &connman)
 
bool AcceptObjectMessage (const uint256 &nHash)
 Called to indicate a requested object has been received. More...
 
bool AcceptVoteMessage (const uint256 &nHash)
 Called to indicate a requested vote has been received. More...
 
void CheckOrphanVotes (CGovernanceObject &govobj, CGovernanceException &exception, CConnman &connman)
 
void RebuildIndexes ()
 
void AddCachedTriggers ()
 
void RequestOrphanObjects (CConnman &connman)
 
void CleanOrphanObjects ()
 
void RemoveInvalidVotes ()
 

Static Private Member Functions

static bool AcceptMessage (const uint256 &nHash, hash_s_t &setHash)
 

Private Attributes

int64_t nTimeLastDiff
 
int nCachedBlockHeight
 
object_m_t mapObjects
 
hash_time_m_t mapErasedGovernanceObjects
 
object_m_t mapPostponedObjects
 
hash_s_t setAdditionalRelayObjects
 
object_ref_cm_t cmapVoteToObject
 
vote_cm_t cmapInvalidVotes
 
vote_cmm_t cmmapOrphanVotes
 
txout_m_t mapLastMasternodeObject
 
hash_s_t setRequestedObjects
 
hash_s_t setRequestedVotes
 
bool fRateChecksEnabled
 
CDeterministicMNList lastMNListForVotingKeys
 

Static Private Attributes

static const int MAX_CACHE_SIZE = 1000000
 
static const std::string SERIALIZATION_VERSION_STRING = "CGovernanceManager-Version-15"
 
static const int MAX_TIME_FUTURE_DEVIATION = 60 * 60
 
static const int RELIABLE_PROPAGATION_TIME = 60
 

Friends

class CGovernanceObject
 

Detailed Description

Definition at line 151 of file governance.h.

Member Typedef Documentation

◆ hash_s_cit

typedef hash_s_t::const_iterator CGovernanceManager::hash_s_cit

Definition at line 205 of file governance.h.

◆ hash_s_it

typedef hash_s_t::iterator CGovernanceManager::hash_s_it

Definition at line 203 of file governance.h.

◆ hash_s_t

Definition at line 201 of file governance.h.

◆ hash_time_m_it

typedef hash_time_m_t::iterator CGovernanceManager::hash_time_m_it

Definition at line 213 of file governance.h.

◆ hash_time_m_t

typedef std::map<uint256, int64_t> CGovernanceManager::hash_time_m_t

Definition at line 211 of file governance.h.

◆ object_info_m_it

typedef object_info_m_t::iterator CGovernanceManager::object_info_m_it

Definition at line 209 of file governance.h.

◆ object_info_m_t

Definition at line 207 of file governance.h.

◆ object_m_cit

typedef object_m_t::const_iterator CGovernanceManager::object_m_cit

Definition at line 181 of file governance.h.

◆ object_m_it

typedef object_m_t::iterator CGovernanceManager::object_m_it

Definition at line 179 of file governance.h.

◆ object_m_t

Definition at line 177 of file governance.h.

◆ object_ref_cm_t

◆ size_type

typedef object_m_t::size_type CGovernanceManager::size_type

Definition at line 195 of file governance.h.

◆ txout_m_it

typedef txout_m_t::iterator CGovernanceManager::txout_m_it

Definition at line 199 of file governance.h.

◆ txout_m_t

Definition at line 197 of file governance.h.

◆ vote_cm_t

◆ vote_cmm_t

◆ vote_m_cit

typedef vote_m_t::const_iterator CGovernanceManager::vote_m_cit

Definition at line 189 of file governance.h.

◆ vote_m_it

typedef vote_m_t::iterator CGovernanceManager::vote_m_it

Definition at line 187 of file governance.h.

◆ vote_m_t

Definition at line 185 of file governance.h.

Constructor & Destructor Documentation

◆ CGovernanceManager()

CGovernanceManager::CGovernanceManager ( )

Definition at line 31 of file governance.cpp.

◆ ~CGovernanceManager()

virtual CGovernanceManager::~CGovernanceManager ( )
inlinevirtual

Definition at line 282 of file governance.h.

Member Function Documentation

◆ AcceptMessage()

bool CGovernanceManager::AcceptMessage ( const uint256 nHash,
hash_s_t setHash 
)
staticprivate

Definition at line 1085 of file governance.cpp.

Referenced by AcceptObjectMessage(), and AcceptVoteMessage().

◆ AcceptObjectMessage()

bool CGovernanceManager::AcceptObjectMessage ( const uint256 nHash)
private

Called to indicate a requested object has been received.

Definition at line 1073 of file governance.cpp.

References AcceptMessage(), cs, LOCK, and setRequestedObjects.

Referenced by ProcessMessage().

◆ AcceptVoteMessage()

bool CGovernanceManager::AcceptVoteMessage ( const uint256 nHash)
private

Called to indicate a requested vote has been received.

Definition at line 1079 of file governance.cpp.

References AcceptMessage(), cs, LOCK, and setRequestedVotes.

Referenced by ProcessMessage().

◆ AddCachedTriggers()

◆ AddGovernanceObject()

◆ AddInvalidVote()

void CGovernanceManager::AddInvalidVote ( const CGovernanceVote vote)
inlineprivate

◆ AddPostponedObject()

void CGovernanceManager::AddPostponedObject ( const CGovernanceObject govobj)
inline

Definition at line 369 of file governance.h.

References cs, CGovernanceObject::GetHash(), LOCK, and mapPostponedObjects.

Referenced by gobject_submit(), and ProcessMessage().

◆ AreRateChecksEnabled()

bool CGovernanceManager::AreRateChecksEnabled ( ) const
inline

Definition at line 392 of file governance.h.

References cs, fRateChecksEnabled, and LOCK.

Referenced by CGovernanceObject::ProcessVote().

◆ CheckAndRemove()

void CGovernanceManager::CheckAndRemove ( )
inline

Definition at line 308 of file governance.h.

References UpdateCachesAndClean().

◆ CheckOrphanVotes()

◆ CheckPostponedObjects()

◆ CleanOrphanObjects()

void CGovernanceManager::CleanOrphanObjects ( )
private

◆ Clear()

◆ ConfirmInventoryRequest()

bool CGovernanceManager::ConfirmInventoryRequest ( const CInv inv)

This is called by AlreadyHave in net_processing.cpp as part of the inventory retrieval process.

Returns true if we want to retrieve the object, otherwise false. (Note logic is inverted in AlreadyHave).

Definition at line 562 of file governance.cpp.

References cmapVoteToObject, cs, BCLog::GOBJECT, CInv::hash, CacheMap< K, V, Size >::HasKey(), CMasternodeSync::IsBlockchainSynced(), LOCK, LogPrint, mapObjects, mapPostponedObjects, masternodeSync, MSG_GOVERNANCE_OBJECT, MSG_GOVERNANCE_OBJECT_VOTE, setRequestedObjects, setRequestedVotes, CInv::ToString(), and CInv::type.

Referenced by AlreadyHave().

◆ DoMaintenance()

void CGovernanceManager::DoMaintenance ( CConnman connman)

◆ FindGovernanceObject()

◆ GetAllNewerThan()

std::vector< const CGovernanceObject * > CGovernanceManager::GetAllNewerThan ( int64_t  nMoreThanTime) const

Definition at line 516 of file governance.cpp.

References cs, LOCK, and mapObjects.

Referenced by ListObjects().

◆ GetCachedBlockHeight()

int CGovernanceManager::GetCachedBlockHeight ( ) const
inline

Definition at line 356 of file governance.h.

References nCachedBlockHeight.

Referenced by CSuperblock::IsExpired().

◆ GetCurrentVotes()

std::vector< CGovernanceVote > CGovernanceManager::GetCurrentVotes ( const uint256 nParentHash,
const COutPoint mnCollateralOutpointFilter 
) const

◆ GetLastDiffTime()

int64_t CGovernanceManager::GetLastDiffTime ( ) const
inline

Definition at line 353 of file governance.h.

References nTimeLastDiff.

Referenced by gobject_diff().

◆ GetVoteCount()

int CGovernanceManager::GetVoteCount ( ) const

Definition at line 74 of file governance.cpp.

References cmapVoteToObject, cs, CacheMap< K, V, Size >::GetSize(), and LOCK.

Referenced by CMasternodeSync::ProcessTick().

◆ HaveObjectForHash()

bool CGovernanceManager::HaveObjectForHash ( const uint256 nHash) const

Definition at line 47 of file governance.cpp.

References cs, LOCK, mapObjects, and mapPostponedObjects.

Referenced by ProcessGetData().

◆ HaveVoteForHash()

bool CGovernanceManager::HaveVoteForHash ( const uint256 nHash) const

◆ InitOnLoad()

void CGovernanceManager::InitOnLoad ( )

Definition at line 1128 of file governance.cpp.

References AddCachedTriggers(), cs, GetTimeMillis(), LOCK, LogPrintf, RebuildIndexes(), and ToString().

Referenced by AppInitMain().

◆ MasternodeRateCheck() [1/2]

bool CGovernanceManager::MasternodeRateCheck ( const CGovernanceObject govobj,
bool  fUpdateFailStatus = false 
)

Definition at line 733 of file governance.cpp.

Referenced by gobject_submit(), and ProcessMessage().

◆ MasternodeRateCheck() [2/2]

◆ MasternodeRateUpdate()

◆ ProcessMessage()

◆ ProcessVote()

◆ ProcessVoteAndRelay()

bool CGovernanceManager::ProcessVoteAndRelay ( const CGovernanceVote vote,
CGovernanceException exception,
CConnman connman 
)
inline

Definition at line 381 of file governance.h.

References ProcessVote(), and CGovernanceVote::Relay().

Referenced by gobject_vote_conf(), voteraw(), and VoteWithMasternodes().

◆ RebuildIndexes()

void CGovernanceManager::RebuildIndexes ( )
private

◆ RemoveInvalidVotes()

◆ RequestGovernanceObject()

◆ RequestGovernanceObjectVotes() [1/2]

int CGovernanceManager::RequestGovernanceObjectVotes ( CNode pnode,
CConnman connman 
)

Definition at line 959 of file governance.cpp.

References MIN_GOVERNANCE_PEER_PROTO_VERSION, and CNode::nVersion.

Referenced by CMasternodeSync::ProcessTick().

◆ RequestGovernanceObjectVotes() [2/2]

◆ RequestOrphanObjects()

◆ SerializationOp()

template<typename Stream , typename Operation >
void CGovernanceManager::SerializationOp ( Stream &  s,
Operation  ser_action 
)
inline

◆ SerializeObjectForHash()

bool CGovernanceManager::SerializeObjectForHash ( const uint256 nHash,
CDataStream ss 
) const

Definition at line 53 of file governance.cpp.

References cs, LOCK, mapObjects, and mapPostponedObjects.

Referenced by ProcessGetData().

◆ SerializeVoteForHash()

bool CGovernanceManager::SerializeVoteForHash ( const uint256 nHash,
CDataStream ss 
) const

◆ SyncObjects()

◆ SyncSingleObjVotes()

◆ ToJson()

◆ ToString()

◆ UpdateCachesAndClean()

◆ UpdatedBlockTip()

◆ UpdateLastDiffTime()

void CGovernanceManager::UpdateLastDiffTime ( int64_t  nTimeIn)
inline

Definition at line 354 of file governance.h.

References nTimeLastDiff.

Referenced by ListObjects().

Friends And Related Function Documentation

◆ CGovernanceObject

friend class CGovernanceObject
friend

Definition at line 153 of file governance.h.

Member Data Documentation

◆ ADD_SERIALIZE_METHODS

CGovernanceManager::ADD_SERIALIZE_METHODS

Definition at line 326 of file governance.h.

◆ cmapInvalidVotes

vote_cm_t CGovernanceManager::cmapInvalidVotes
private

Definition at line 241 of file governance.h.

Referenced by AddInvalidVote(), Clear(), ProcessVote(), RemoveInvalidVotes(), and SerializationOp().

◆ cmapVoteToObject

◆ cmmapOrphanVotes

vote_cmm_t CGovernanceManager::cmmapOrphanVotes
private

◆ cs

◆ fRateChecksEnabled

bool CGovernanceManager::fRateChecksEnabled
private

◆ lastMNListForVotingKeys

CDeterministicMNList CGovernanceManager::lastMNListForVotingKeys
private

Definition at line 254 of file governance.h.

Referenced by RemoveInvalidVotes(), and SerializationOp().

◆ mapErasedGovernanceObjects

hash_time_m_t CGovernanceManager::mapErasedGovernanceObjects
private

◆ mapLastMasternodeObject

txout_m_t CGovernanceManager::mapLastMasternodeObject
private

Definition at line 245 of file governance.h.

Referenced by Clear(), MasternodeRateCheck(), MasternodeRateUpdate(), and SerializationOp().

◆ mapObjects

◆ mapPostponedObjects

object_m_t CGovernanceManager::mapPostponedObjects
private

◆ MAX_CACHE_SIZE

const int CGovernanceManager::MAX_CACHE_SIZE = 1000000
staticprivate

Definition at line 216 of file governance.h.

◆ MAX_TIME_FUTURE_DEVIATION

const int CGovernanceManager::MAX_TIME_FUTURE_DEVIATION = 60 * 60
staticprivate

Definition at line 220 of file governance.h.

Referenced by CheckPostponedObjects(), MasternodeRateCheck(), and MasternodeRateUpdate().

◆ nCachedBlockHeight

int CGovernanceManager::nCachedBlockHeight
private

◆ nTimeLastDiff

int64_t CGovernanceManager::nTimeLastDiff
private

Definition at line 223 of file governance.h.

Referenced by GetLastDiffTime(), and UpdateLastDiffTime().

◆ RELIABLE_PROPAGATION_TIME

const int CGovernanceManager::RELIABLE_PROPAGATION_TIME = 60
staticprivate

Definition at line 221 of file governance.h.

Referenced by CheckPostponedObjects(), and MasternodeRateUpdate().

◆ SERIALIZATION_VERSION_STRING

const std::string CGovernanceManager::SERIALIZATION_VERSION_STRING = "CGovernanceManager-Version-15"
staticprivate

Definition at line 218 of file governance.h.

Referenced by SerializationOp().

◆ setAdditionalRelayObjects

hash_s_t CGovernanceManager::setAdditionalRelayObjects
private

Definition at line 237 of file governance.h.

Referenced by CheckPostponedObjects(), and MasternodeRateUpdate().

◆ setRequestedObjects

hash_s_t CGovernanceManager::setRequestedObjects
private

Definition at line 247 of file governance.h.

Referenced by AcceptObjectMessage(), and ConfirmInventoryRequest().

◆ setRequestedVotes

hash_s_t CGovernanceManager::setRequestedVotes
private

Definition at line 249 of file governance.h.

Referenced by AcceptVoteMessage(), ConfirmInventoryRequest(), and RemoveInvalidVotes().


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