28 fCachedLocalValidity(false),
29 strLocalValidityError(),
30 fCachedFunding(false),
33 fCachedEndorsed(false),
48 nHashParent(nHashParentIn),
49 nRevision(nRevisionIn),
52 nCollateralHash(nCollateralHashIn),
56 fCachedLocalValidity(false),
57 strLocalValidityError(),
58 fCachedFunding(false),
61 fCachedEndorsed(false),
75 nObjectType(other.nObjectType),
76 nHashParent(other.nHashParent),
77 nRevision(other.nRevision),
79 nDeletionTime(other.nDeletionTime),
80 nCollateralHash(other.nCollateralHash),
81 strData(other.strData),
84 fCachedLocalValidity(other.fCachedLocalValidity),
85 strLocalValidityError(other.strLocalValidityError),
86 fCachedFunding(other.fCachedFunding),
87 fCachedValid(other.fCachedValid),
88 fCachedDelete(other.fCachedDelete),
89 fCachedEndorsed(other.fCachedEndorsed),
90 fDirtyCache(other.fDirtyCache),
91 fExpired(other.fExpired),
92 fUnparsable(other.fUnparsable),
93 mapCurrentMNVotes(other.mapCurrentMNVotes),
94 mapOrphanVotes(other.mapOrphanVotes),
95 fileVotes(other.fileVotes)
104 std::ostringstream ostr;
105 ostr <<
"CGovernanceObject::ProcessVote -- Masternode index not found";
114 LogPrint(
"gobject",
"%s\n", ostr.str());
126 std::ostringstream ostr;
127 ostr <<
"CGovernanceObject::ProcessVote -- Vote signal: none";
128 LogPrint(
"gobject",
"%s\n", ostr.str());
133 std::ostringstream ostr;
147 std::ostringstream ostr;
148 ostr <<
"CGovernanceObject::ProcessVote -- Obsolete vote";
149 LogPrint(
"gobject",
"%s\n", ostr.str());
155 int64_t nVoteTimeUpdate = voteInstance.
nTime;
157 int64_t nTimeDelta = nNow - voteInstance.
nTime;
159 std::ostringstream ostr;
160 ostr <<
"CGovernanceObject::ProcessVote -- Masternode voting too often" 163 <<
", time delta = " << nTimeDelta;
164 LogPrint(
"gobject",
"%s\n", ostr.str());
166 nVoteTimeUpdate = nNow;
172 std::ostringstream ostr;
173 ostr <<
"CGovernanceObject::ProcessVote -- Invalid vote" 183 std::ostringstream ostr;
184 ostr <<
"CGovernanceObject::ProcessVote -- Unable to add governance vote" 187 LogPrint(
"gobject",
"%s\n", ostr.str());
217 boost::lexical_cast<std::string>(
nRevision) +
"|" +
218 boost::lexical_cast<std::string>(
nTime) +
"|" +
233 std::string strError;
239 LogPrintf(
"CGovernanceObject::Sign -- SignMessage() failed\n");
244 LogPrintf(
"CGovernanceObject::Sign -- VerifyMessage() failed, error: %s\n", strError);
248 LogPrint(
"gobject",
"CGovernanceObject::Sign -- pubkey id = %s, vin = %s\n",
257 std::string strError;
263 LogPrintf(
"CGovernance::CheckSignature -- VerifyMessage() failed, error: %s\n", strError);
313 std::vector<UniValue> arr1 = objResult.
getValues();
314 std::vector<UniValue> arr2 = arr1.at( 0 ).getValues();
342 DBG( cout <<
"CGovernanceObject::LoadData strData = " 349 catch(std::exception& e) {
351 std::ostringstream ostr;
352 ostr <<
"CGovernanceObject::LoadData Error parsing JSON" 353 <<
", e.what() = " << e.what();
354 DBG( cout << ostr.str() << endl; );
360 std::ostringstream ostr;
361 ostr <<
"CGovernanceObject::LoadData Unknown Error parsing JSON";
362 DBG( cout << ostr.str() << endl; );
398 std::string s(v.begin(), v.end());
413 bool fMissingMasternode =
false;
414 bool fMissingConfirmations =
false;
416 return IsValidLocally(strError, fMissingMasternode, fMissingConfirmations, fCheckCollateral);
421 fMissingMasternode =
false;
422 fMissingConfirmations =
false;
425 strError =
"Object data unparseable";
443 if(fCheckCollateral) {
451 fMissingMasternode =
true;
452 strError =
"Masternode not found: " + strOutpoint;
454 strError =
"Failed to find Masternode UTXO, missing masternode=" + strOutpoint +
"\n";
456 strError =
"Masternode UTXO should have 1000 DASH, missing masternode=" + strOutpoint +
"\n";
505 fMissingConfirmations =
false;
516 LogPrintf(
"CGovernanceObject::IsCollateralValid -- %s\n", strError);
520 if(txCollateral.
vout.size() < 1) {
521 strError =
strprintf(
"tx vout size less than 1 | %d", txCollateral.
vout.size());
522 LogPrintf(
"CGovernanceObject::IsCollateralValid -- %s\n", strError);
531 DBG( cout <<
"IsCollateralValid: txCollateral.vout.size() = " << txCollateral.
vout.size() << endl; );
533 DBG( cout <<
"IsCollateralValid: findScript = " <<
ScriptToAsmStr( findScript,
false ) << endl; );
535 DBG( cout <<
"IsCollateralValid: nMinFee = " << nMinFee << endl; );
538 bool foundOpReturn =
false;
539 BOOST_FOREACH(
const CTxOut o, txCollateral.
vout) {
540 DBG( cout <<
"IsCollateralValid txout : " << o.
ToString()
541 <<
", o.nValue = " << o.
nValue 546 LogPrintf (
"CGovernanceObject::IsCollateralValid -- %s\n", strError);
550 DBG( cout <<
"IsCollateralValid foundOpReturn = true" << endl; );
551 foundOpReturn =
true;
554 DBG( cout <<
"IsCollateralValid No match, continuing" << endl; );
561 LogPrintf (
"CGovernanceObject::IsCollateralValid -- %s\n", strError);
582 fMissingConfirmations =
true;
583 strError +=
", pre-accepted -- waiting for required confirmations";
585 strError +=
", rejected -- try again later";
587 LogPrintf (
"CGovernanceObject::IsCollateralValid -- %s\n", strError);
606 if(voteInstance.
eOutcome == eVoteOutcomeIn) {
648 voteRecord = it->second;
663 if(nMnCount == 0)
return;
668 int nAbsVoteReq = std::max(
Params().GetConsensus().nGovernanceMinQuorum, nMnCount / 10);
669 int nAbsDeleteReq = std::max(
Params().GetConsensus().nGovernanceMinQuorum, (2 * nMnCount) / 3);
724 while(it != listVotes.end()) {
725 bool fRemove =
false;
729 if(pairVote.second < nNow) {
738 LogPrintf(
"CGovernanceObject::CheckOrphanVotes -- Failed to add orphan vote: %s\n", exception.
what());
void UpdateSentinelVariables()
bool AreRateChecksEnabled() const
bool GetCurrentMNVotes(const COutPoint &mnCollateralOutpoint, vote_rec_t &voteRecord)
int64_t GetTimestamp() const
static const int64_t GOVERNANCE_FEE_CONFIRMATIONS
static const int64_t GOVERNANCE_ORPHAN_EXPIRATION_TIME
vote_m_t::iterator vote_m_it
bool Insert(const K &key, const V &value)
std::pair< CGovernanceVote, int64_t > vote_time_pair_t
bool fCachedValid
true == minimum network has been reached flagging this object as a valid and understood goverance obj...
static const CAmount MAX_MONEY
vote_instance_m_t mapInstances
static const int MIN_GOVERNANCE_PEER_PROTO_VERSION
void AddVote(const CGovernanceVote &vote)
static const CAmount GOVERNANCE_PROPOSAL_FEE_TX
bool fCachedLocalValidity
is valid by blockchain
Default value, normally indicates no exception condition occurred.
bool fUnparsable
Failed to parse object data.
std::string strLocalValidityError
static const int64_t GOVERNANCE_MIN_RELAY_FEE_CONFIRMATIONS
static const int GOVERNANCE_OBJECT_PROPOSAL
int CountMatchingVotes(vote_signal_enum_t eVoteSignalIn, vote_outcome_enum_t eVoteOutcomeIn) const
CGovernanceObjectVoteFile fileVotes
void RelayInv(CInv &inv, const int minProtoVersion=MIN_PEER_PROTO_VERSION)
vote_outcome_enum_t GetOutcome() const
void AskForMN(CNode *pnode, const COutPoint &outpoint, CConnman &connman)
Ask (source) node for mnb.
void ClearMasternodeVotes()
Called when MN's which have voted on this object have been removed.
bool fExpired
Object is no longer of interest.
vote_outcome_enum_t eOutcome
Requested operation cannot be performed.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
const list_t & GetItemList() const
int nObjectType
Object typecode.
bool Contains(const CBlockIndex *pindex) const
static CollateralStatus CheckCollateral(const COutPoint &outpoint)
#define AssertLockHeld(cs)
vote_signal_enum_t GetSignal() const
bool IsUnspendable() const
std::string GetSignatureMessage() const
Requested operation not currently possible, may resubmit later.
std::string ScriptToAsmStr(const CScript &script, const bool fAttemptSighashDecode=false)
static const int GOVERNANCE_OBJECT_WATCHDOG
static int LogPrint(const char *category, const char *format)
int GetConfirmations(const uint256 &nTXHash)
void Relay(CConnman &connman)
bool fDirtyCache
object was updated and cached values should be updated soon
const COutPoint & GetMasternodeOutpoint() const
int64_t nDeletionTime
time this object was marked for deletion
std::string strData
Data field - can be used for anything.
vote_m_t::const_iterator vote_m_cit
bool GetMasternodeInfo(const COutPoint &outpoint, masternode_info_t &mnInfoRet)
int GetYesCount(vote_signal_enum_t eVoteSignalIn) const
std::string GetDataAsHex()
bool IsNormalPaymentScript() const
int GetAbsoluteNoCount(vote_signal_enum_t eVoteSignalIn) const
static const int GOVERNANCE_OBJECT_TRIGGER
vector< unsigned char > ParseHex(const char *psz)
std::string GetDataAsString()
void RemoveVotesFromMasternode(const COutPoint &outpointMasternode)
static bool VerifyMessage(const CPubKey pubkey, const std::vector< unsigned char > &vchSig, const std::string strMessage, std::string &strErrorRet)
Verify the message signature, returns true if succcessful.
std::string ToString() const
bool AddGovernanceVote(const COutPoint &outpoint, uint256 nGovernanceObjectHash)
bool IsCollateralValid(std::string &strError, bool &fMissingConfirmations)
Check the collateral transaction for the budget proposal/finalized budget.
void AddInvalidVote(const CGovernanceVote &vote)
list_t::const_iterator list_cit
vote_mcache_t mapOrphanVotes
Limited map of votes orphaned by MN.
bool CheckSignature(CPubKey &pubKeyMasternode)
bool IsValidLocally(std::string &strError, bool fCheckCollateral)
void swap(CGovernanceObject &first, CGovernanceObject &second)
bool HasVote(const uint256 &nHash) const
void SetMasternodeVin(const COutPoint &outpoint)
void GetData(UniValue &objResult)
int CountEnabled(int nProtocolVersion=-1)
int GetAbstainCount(vote_signal_enum_t eVoteSignalIn) const
std::vector< unsigned char > vchSig
CCriticalSection cs
critical section to protect the inner data structures
const uint256 & GetParentHash() const
const CChainParams & Params()
static const int64_t GOVERNANCE_UPDATE_MIN
Unusual condition requiring no caller action.
std::string ToString() const
bool Sign(CKey &keyMasternode, CPubKey &pubKeyMasternode)
static const int PROTOCOL_VERSION
int GetAbsoluteYesCount(vote_signal_enum_t eVoteSignalIn) const
int64_t GetAdjustedTime()
std::string ToString() const
CTxIn vinMasternode
Masternode info for signed objects.
const std::vector< CTxOut > vout
uint256 nHashParent
parent object, 0 is root
std::list< item_t > list_t
static const int GOVERNANCE_OBJECT_UNKNOWN
uint256 nCollateralHash
fee-tx
static std::string ConvertSignalToString(vote_signal_enum_t nSignal)
bool Has(const COutPoint &outpoint)
bool fCachedFunding
true == minimum network support has been reached for this object to be funded (doesn't mean it will f...
virtual uint256 GetHash()=0
static bool SignMessage(const std::string strMessage, std::vector< unsigned char > &vchSigRet, const CKey key)
Sign the message, returns true if successful.
int GetNoCount(vote_signal_enum_t eVoteSignalIn) const
static const int TRIGGER_SUPERBLOCK
bool GetTransaction(const uint256 &hash, CTransaction &txOut, const Consensus::Params &consensusParams, uint256 &hashBlock, bool fAllowSlow)
CGovernanceManager governance
virtual const char * what() const
int64_t nTime
time this object was created
std::vector< unsigned char > vchSig
void Relay(CConnman &connman) const
bool read(const char *raw)
void CheckOrphanVotes(CConnman &connman)
int nHeight
height of the entry in the chain. The genesis block has height 0
std::string ToStringShort() const
static const int MAX_SUPPORTED_VOTE_SIGNAL
vote_m_t mapCurrentMNVotes
CAmount GetMinCollateralFee()
bool ProcessVote(CNode *pfrom, const CGovernanceVote &vote, CGovernanceException &exception, CConnman &connman)
vote_instance_m_t::const_iterator vote_instance_m_cit
vote_instance_m_t::iterator vote_instance_m_it
void UpdateLocalValidity()
bool fCachedDelete
true == minimum network support has been reached saying this object should be deleted from the system...
std::vector< unsigned char > ToByteVector(const T &in)
int nRevision
object revision in the system
std::vector< UniValue > getValues() const