Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
governance-object.cpp
Go to the documentation of this file.
48 CGovernanceObject::CGovernanceObject(const uint256& nHashParentIn, int nRevisionIn, int64_t nTimeIn, const uint256& nCollateralHashIn, const std::string& strDataHexIn) :
122 ostr << "CGovernanceObject::ProcessVote -- Masternode " << vote.GetMasternodeOutpoint().ToStringShort() << " not found";
127 vote_m_it it = mapCurrentMNVotes.emplace(vote_m_t::value_type(vote.GetMasternodeOutpoint(), vote_rec_t())).first;
139 ostr << "CGovernanceObject::ProcessVote -- Unsupported vote signal: " << CGovernanceVoting::ConvertSignalToString(vote.GetSignal());
144 vote_instance_m_it it2 = voteRecordRef.mapInstances.emplace(vote_instance_m_t::value_type(int(eSignal), vote_instance_t())).first;
158 ostr << "CGovernanceObject::ProcessVote -- Invalid vote, same timestamp for the different outcome";
188 bool onlyVotingKeyAllowed = nObjectType == GOVERNANCE_OBJECT_PROPOSAL && vote.GetSignal() == VOTE_SIGNAL_FUNDING;
190 // Finally check that the vote is actually valid (done last because of cost of signature verification)
247 auto removedVotes = fileVotes.RemoveInvalidVotes(mnOutpoint, nObjectType == GOVERNANCE_OBJECT_PROPOSAL);
254 CGovernanceVote tmpVote(mnOutpoint, nParentHash, (vote_signal_enum_t)jt->first, jt->second.eOutcome);
271 LogPrintf("CGovernanceObject::%s -- Removed %d invalid votes for %s from MN %s:\n%s", __func__, removedVotes.size(), nParentHash.ToString(), mnOutpoint.ToString(), removedStr); /* Continued */
289 ss << masternodeOutpoint << uint8_t{} << 0xffffffff; // adding dummy values here to match old hashing
371 LogPrint(BCLog::GOBJECT, "CGovernanceObject::LoadData -- GetDataAsPlainString = %s\n", GetDataAsPlainString());
437 bool CGovernanceObject::IsValidLocally(std::string& strError, bool& fMissingConfirmations, bool fCheckCollateral) const
453 strError = strprintf("Invalid proposal data, error messages: %s", validator.GetErrorMessages());
479 strError = "Invalid masternode signature for: " + strOutpoint + ", pubkey = " + dmn->pdmnState->pubKeyOperator.Get().ToString();
505 bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingConfirmations) const
517 if (!GetTransaction(nCollateralHash, txCollateral, Params().GetConsensus(), nBlockHash, true)) {
540 LogPrint(BCLog::GOBJECT, "CGovernanceObject::IsCollateralValid -- txCollateral->vout.size() = %s, findScript = %s, nMinFee = %lld\n",
545 LogPrint(BCLog::GOBJECT, "CGovernanceObject::IsCollateralValid -- txout = %s, output.nValue = %lld, output.scriptPubKey = %s\n",
558 strError = strprintf("Couldn't find opReturn %s in %s", nExpectedHash.ToString(), txCollateral->ToString());
578 strError = strprintf("Collateral requires at least %d confirmations to be relayed throughout the network (it has only %d)", GOVERNANCE_FEE_CONFIRMATIONS, nConfirmationsIn);
594 int CGovernanceObject::CountMatchingVotes(vote_signal_enum_t eVoteSignalIn, vote_outcome_enum_t eVoteOutcomeIn) const
638 bool CGovernanceObject::GetCurrentMNVotes(const COutPoint& mnCollateralOutpoint, vote_rec_t& voteRecord) const
bool IsCollateralValid(std::string &strError, bool &fMissingConfirmations) const
Check the collateral transaction for the budget proposal/finalized budget.
Definition: governance-object.cpp:505
bool HasVote(const uint256 &nHash) const
Return true if the vote with this hash is currently cached in memory.
Definition: governance-votedb.cpp:34
bool GetTransaction(const uint256 &hash, CTransactionRef &txOut, const Consensus::Params &consensusParams, uint256 &hashBlock, bool fAllowSlow, CBlockIndex *blockIndex)
Return transaction in txOut, and if it was found inside a block, its hash is placed in hashBlock...
Definition: validation.cpp:950
static const int64_t GOVERNANCE_FEE_CONFIRMATIONS
Definition: governance-object.h:38
Definition: governance-vote.h:27
Definition: bls.h:238
static const CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition: amount.h:26
int GetAbstainCount(vote_signal_enum_t eVoteSignalIn) const
Definition: governance-object.cpp:633
Definition: governance-vote.h:28
static const int MIN_GOVERNANCE_PEER_PROTO_VERSION
Definition: governance-object.h:26
Definition: governance-vote.h:54
bool CheckSignature(const CBLSPublicKey &pubKey) const
Definition: governance-object.cpp:316
static const CAmount GOVERNANCE_PROPOSAL_FEE_TX
Definition: governance-object.h:36
Default value, normally indicates no exception condition occurred.
Definition: governance-exceptions.h:15
std::string HexStr(const T itbegin, const T itend, bool fSpaces=false)
Definition: utilstrencodings.h:100
std::string strLocalValidityError
Definition: governance-object.h:149
Definition: governance-validators.h:12
Definition: univalue.h:20
void SetMasternodeOutpoint(const COutPoint &outpoint)
Definition: governance-object.cpp:301
static const int64_t GOVERNANCE_MIN_RELAY_FEE_CONFIRMATIONS
Definition: governance-object.h:39
static const int GOVERNANCE_OBJECT_PROPOSAL
Definition: governance-object.h:33
bool VerifyInsecure(const CBLSPublicKey &pubKey, const uint256 &hash) const
Definition: bls.cpp:335
Definition: governance-object.h:57
Definition: governance-vote.h:18
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
Definition: deterministicmns.cpp:24
Requested operation cannot be performed.
Definition: governance-exceptions.h:19
const std::string & GetErrorMessages()
Definition: governance-validators.h:25
bool fCachedFunding
true == minimum network support has been reached for this object to be funded (doesn't mean it will f...
Definition: governance-object.h:154
const COutPoint & GetMasternodeOutpoint() const
Definition: governance-vote.h:105
UniValue GetJSONObject()
Return the actual object from the vchData JSON structure.
Definition: governance-object.cpp:332
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
Definition: hash.h:254
Definition: univalue.h:22
bool ProcessVote(CNode *pfrom, const CGovernanceVote &vote, CGovernanceException &exception, CConnman &connman)
Definition: governance-object.cpp:100
Definition: script.h:86
Definition: governance-object.h:90
int GetNoCount(vote_signal_enum_t eVoteSignalIn) const
Definition: governance-object.cpp:628
Requested operation not currently possible, may resubmit later.
Definition: governance-exceptions.h:21
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
Create the assembly string representation of a CScript object.
Definition: core_write.cpp:86
std::set< uint256 > RemoveInvalidVotes(const COutPoint &mnOutpoint)
Definition: governance-object.cpp:237
void RemoveVotesFromMasternode(const COutPoint &outpointMasternode)
Definition: governance-votedb.cpp:58
Definition: bls.h:263
bool fCachedValid
true == minimum network has been reached flagging this object as a valid and understood governance ob...
Definition: governance-object.h:157
bool Validate(bool fCheckExpiration=true)
Definition: governance-validators.cpp:38
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
Definition: chain.h:471
Definition: bls.h:286
Definition: util.h:134
static const int GOVERNANCE_OBJECT_TRIGGER
Definition: governance-object.h:34
int GetAbsoluteNoCount(vote_signal_enum_t eVoteSignalIn) const
Definition: governance-object.cpp:618
A class which encapsulates information about a governance exception condition.
Definition: governance-exceptions.h:55
Definition: governance-vote.h:20
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
uint256 GetSignatureHash() const
Definition: governance-object.cpp:296
Definition: governance-vote.h:29
std::vector< unsigned char > vchData
Data field - can be used for anything.
Definition: governance-object.h:141
bool IsValidLocally(std::string &strError, bool fCheckCollateral) const
Definition: governance-object.cpp:430
Definition: governance-vote.h:19
std::string GetDataAsPlainString() const
Definition: governance-object.cpp:417
void AddVote(const CGovernanceVote &vote)
Add a vote to the file.
Definition: governance-votedb.cpp:22
void UpdateSentinelVariables()
Definition: governance-object.cpp:662
void ClearMasternodeVotes()
Called when MN's which have voted on this object have been removed.
Definition: governance-object.cpp:219
Definition: governance-vote.h:26
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:947
int GetAbsoluteYesCount(vote_signal_enum_t eVoteSignalIn) const
Get specific vote counts for each outcome (funding, validity, etc)
Definition: governance-object.cpp:613
Unusual condition requiring no caller action.
Definition: governance-exceptions.h:17
CAmount GetMinCollateralFee() const
Definition: governance-object.cpp:492
int GetYesCount(vote_signal_enum_t eVoteSignalIn) const
Definition: governance-object.cpp:623
void RelayInv(CInv &inv, const int minProtoVersion=MIN_PEER_PROTO_VERSION, bool fAllowMasternodeConnections=false)
Definition: net.cpp:3482
static const int GOVERNANCE_OBJECT_UNKNOWN
Definition: governance-object.h:32
int CountMatchingVotes(vote_signal_enum_t eVoteSignalIn, vote_outcome_enum_t eVoteOutcomeIn) const
Definition: governance-object.cpp:594
bool AreRateChecksEnabled() const
Definition: governance.h:392
static std::string ConvertSignalToString(vote_signal_enum_t nSignal)
Definition: governance-vote.cpp:30
bool fCachedEndorsed
true == minimum network support has been reached flagging this object as endorsed by an elected repre...
Definition: governance-object.h:165
Definition: protocol.h:410
CChain & chainActive
The currently-connected chain of blocks (protected by cs_main).
Definition: validation.cpp:217
AssertLockHeld(g_cs_orphans)
std::set< uint256 > RemoveInvalidVotes(const COutPoint &outpointMasternode, bool fProposal)
Definition: governance-votedb.cpp:72
void UpdateLocalValidity()
Definition: governance-object.cpp:422
bool AddGovernanceVote(const uint256 &proTxHash, const uint256 &nGovernanceObjectHash)
Definition: masternode-meta.cpp:93
bool fDirtyCache
object was updated and cached values should be updated soon
Definition: governance-object.h:168
void AddInvalidVote(const CGovernanceVote &vote)
Definition: governance.h:406
Definition: serialize.h:162
bool fCachedDelete
true == minimum network support has been reached saying this object should be deleted from the system...
Definition: governance-object.h:160
CCriticalSection cs
critical section to protect the inner data structures
Definition: governance-object.h:120
Definition: governance-vote.h:30
bool GetCurrentMNVotes(const COutPoint &mnCollateralOutpoint, vote_rec_t &voteRecord) const
Definition: governance-object.cpp:638
vote_instance_m_t::const_iterator vote_instance_m_cit
Definition: governance-object.h:88