diff --git a/src/governance.cpp b/src/governance.cpp index 5ba5b4efa..334e45118 100644 --- a/src/governance.cpp +++ b/src/governance.cpp @@ -564,29 +564,24 @@ CGovernanceObject::CGovernanceObject() } -CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, std::string strNameIn, int64_t nTime, uint256 nFeeTXHashIn) +CGovernanceObject::CGovernanceObject(uint256 nHashParentIn, int nRevisionIn, std::string strNameIn, int64_t nTimeIn, uint256 nFeeTXHashIn) { - strName = "unknown"; - nTime = 0; - nHashParent = nHashParentIn; //parent object, 0 is root - // nPriority = nPriorityIn; nRevision = nRevisionIn; //object revision in the system + strName = strNameIn; + nTime = nTimeIn; nFeeTXHash = nFeeTXHashIn; //fee-tx - // nTypeVersion = nTypeVersionIn; } CGovernanceObject::CGovernanceObject(const CGovernanceObject& other) { + // COPY OTHER OBJECT'S DATA INTO THIS OBJECT + + nHashParent = other.nHashParent; + nRevision = other.nRevision; strName = other.strName; nTime = other.nTime; - - nHashParent = other.nHashParent; //parent object, 0 is root - // nPriority = other.nPriorityIn; - nRevision = other.nRevision; //object revision in the system - nFeeTXHash = other.nFeeTXHash; //fee-tx - // nTypeVersion = other.nTypeVersion; - //?? + nFeeTXHash = other.nFeeTXHash; strData = other.strData; } diff --git a/src/governance.h b/src/governance.h index 9951a56be..d65cbd2cd 100644 --- a/src/governance.h +++ b/src/governance.h @@ -182,22 +182,20 @@ public: void UpdateLocalValidity(const CBlockIndex *pCurrentBlockIndex) {fCachedLocalValidity = IsValid(pCurrentBlockIndex, strLocalValidityError);}; void UpdateSentinelVariables(const CBlockIndex *pCurrentBlockIndex) { - /* - #define VOTE_SIGNAL_FUNDING 1 // -- fund this object for it's stated amount - #define VOTE_SIGNAL_VALID 2 // -- this object checks out to sentinel - #define VOTE_SIGNAL_DELETE 3 // -- this object should be deleted from memory entirely - #define VOTE_SIGNAL_ENDORSED 5 // -- officially endorsed by the network somehow (delegation) - */ + // CALCULATE MINIMUM SUPPORT LEVELS REQUIRED int nMnCount = mnodeman.CountEnabled(); int nAbsYesVoteReq = nMnCount / 10; - // set all flags to false + // SET SENTINEL FLAGS TO FALSE + fCachedFunding = false; fCachedValid = false; fCachedDelete = false; fCachedEndorsed = false; + // SET SENTINEL FLAGS TO TRUE IF MIMIMUM SUPPORT LEVELS ARE REACHED + if(GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING) >= nAbsYesVoteReq) fCachedFunding = true; if(GetAbsoluteYesCount(VOTE_SIGNAL_VALID) >= nAbsYesVoteReq) fCachedValid = true; if(GetAbsoluteYesCount(VOTE_SIGNAL_DELETE) >= nAbsYesVoteReq) fCachedDelete = true; @@ -242,13 +240,7 @@ public: uint256 GetHash(){ - /* - uint256 nHashParent; //parent object, 0 is root - int nRevision; //object revision in the system - std::string strName; //org name, username, prop name, etc. - int64_t nTime; //time this object was created - uint256 nFeeTXHash; //fee-tx - */ + // CREATE HASH OF ALL IMPORTANT PIECES OF DATA CHashWriter ss(SER_GETHASH, PROTOCOL_VERSION); ss << nHashParent; @@ -256,27 +248,27 @@ public: ss << strName; ss << nTime; ss << strData; + // fee_tx is left out on purpose uint256 h1 = ss.GetHash(); return h1; } /** - * AddRegister - Example usage: + * SetData - Example usage: * -------------------------------------------------------- * - * We don't really care what's in these, as long as the masternode network - * believes they're accurate. Otherwise the masternodes will vote them down - * and we'll delete them from memory (fee-loss attack). - * - + * dash-core is data-agnostic, for rules about data see sentinel documentation + * */ bool SetData(std::string& strError, std::string strDataIn) { - // (assumption) this is equal to pythons len(strData) > 512*4, I think + // SET DATA FIELD TO INPUT + if(strDataIn.size() > 512*4) { + // (assumption) this is equal to pythons len(strData) > 512*4, I think strError = "Too big."; return false; } @@ -290,27 +282,7 @@ public: template inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { - /** - * Store all major data items in serialization for other clients - * -- - * - * - * uint256 nHashParent; //parent object, 0 is root - * int nRevision; //object revision in the system - * std::string strName; //org name, username, prop name, etc. - * int64_t nTime; //time this object was created - * uint256 nFeeTXHash; //fee-tx - * - * // caching - * bool fValid; - * uint256 nHash; - * - * // Registers, these can be used for anything - * // -- check governance wiki for correct usage - * std::map mapRegister; - * - * - */ + // SERIALIZE DATA FOR SAVING/LOADING OR NETWORK FUNCTIONS READWRITE(nHashParent); READWRITE(nRevision); diff --git a/src/rpcmasternode-budget.cpp b/src/rpcmasternode-budget.cpp index 1367535be..d591e8982 100644 --- a/src/rpcmasternode-budget.cpp +++ b/src/rpcmasternode-budget.cpp @@ -82,11 +82,31 @@ UniValue mngovernance(const UniValue& params, bool fHelp) " vote-alias - Vote on a governance object by masternode alias\n" ); + + /* + + + 12.1 todo - + + + Example Governance Item + - This should be valid for anyone to submit + - This should propagate and show up when syncing + + + Command: + mngovernance submit 71cd63efd90bb33bae023065b105a597168c0e126dc07e68693854f132f73997 0 1 1463588860 "beer-reimbursement" + + + */ + if(strCommand == "prepare") { if (params.size() != 6) throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'mngovernance prepare