2016-04-09 21:57:53 +02:00
// Copyright (c) 2014-2016 The Dash Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2016-09-12 09:40:00 +02:00
2016-11-13 18:52:34 +01:00
# ifndef GOVERNANCE_H
# define GOVERNANCE_H
2016-04-09 21:57:53 +02:00
2016-08-17 09:08:25 +02:00
//#define ENABLE_DASH_DEBUG
# include "util.h"
2016-04-09 21:57:53 +02:00
# include "main.h"
# include "sync.h"
# include "net.h"
# include "key.h"
# include "util.h"
# include "base58.h"
# include "masternode.h"
2016-11-13 18:52:34 +01:00
# include "governance-exceptions.h"
2016-04-14 00:41:40 +02:00
# include "governance-vote.h"
2016-11-13 18:52:34 +01:00
# include "governance-votedb.h"
2016-05-25 18:56:58 +02:00
# include "masternodeman.h"
2016-04-09 21:57:53 +02:00
# include <boost/lexical_cast.hpp>
# include "init.h"
2016-08-17 09:08:25 +02:00
# include <univalue.h>
# include "utilstrencodings.h"
2016-11-13 18:52:34 +01:00
# include "cachemap.h"
# include "cachemultimap.h"
2016-04-09 21:57:53 +02:00
2016-04-16 19:19:17 +02:00
# include <stdio.h>
# include <string.h>
2016-09-12 09:40:00 +02:00
class CGovernanceManager ;
2016-11-13 18:52:34 +01:00
class CGovernanceTriggerManager ;
2016-09-12 09:40:00 +02:00
class CGovernanceObject ;
class CGovernanceVote ;
2016-08-17 09:08:25 +02:00
2016-09-17 21:37:48 +02:00
static const int MAX_GOVERNANCE_OBJECT_DATA_SIZE = 16 * 1024 ;
2016-09-30 20:19:26 +02:00
static const int MIN_GOVERNANCE_PEER_PROTO_VERSION = 70202 ;
2016-09-17 21:37:48 +02:00
2016-08-17 09:08:25 +02:00
static const int GOVERNANCE_OBJECT_UNKNOWN = 0 ;
static const int GOVERNANCE_OBJECT_PROPOSAL = 1 ;
static const int GOVERNANCE_OBJECT_TRIGGER = 2 ;
2016-10-17 20:54:28 +02:00
static const int GOVERNANCE_OBJECT_WATCHDOG = 3 ;
2016-08-17 09:08:25 +02:00
2016-09-05 01:44:10 +02:00
static const CAmount GOVERNANCE_PROPOSAL_FEE_TX = ( 0.33 * COIN ) ;
static const int64_t GOVERNANCE_FEE_CONFIRMATIONS = 6 ;
2016-04-10 02:43:15 +02:00
static const int64_t GOVERNANCE_UPDATE_MIN = 60 * 60 ;
2016-04-09 21:57:53 +02:00
2016-05-13 18:03:01 +02:00
// FOR SEEN MAP ARRAYS - GOVERNANCE OBJECTS AND VOTES
2016-08-17 09:08:25 +02:00
static const int SEEN_OBJECT_IS_VALID = 0 ;
static const int SEEN_OBJECT_ERROR_INVALID = 1 ;
static const int SEEN_OBJECT_ERROR_IMMATURE = 2 ;
static const int SEEN_OBJECT_EXECUTED = 3 ; //used for triggers
static const int SEEN_OBJECT_UNKNOWN = 4 ; // the default
2016-05-13 18:03:01 +02:00
2016-09-12 09:40:00 +02:00
extern std : : map < uint256 , int64_t > mapAskedForGovernanceObject ;
extern CGovernanceManager governance ;
2016-04-09 21:57:53 +02:00
//
2016-04-09 22:31:01 +02:00
// Governance Manager : Contains all proposals for the budget
2016-04-09 21:57:53 +02:00
//
2016-04-09 22:31:01 +02:00
class CGovernanceManager
2016-04-09 21:57:53 +02:00
{
2016-11-13 18:52:34 +01:00
friend class CGovernanceObject ;
2016-08-17 09:08:25 +02:00
public : // Types
typedef std : : map < uint256 , CGovernanceObject > object_m_t ;
typedef object_m_t : : iterator object_m_it ;
typedef object_m_t : : const_iterator object_m_cit ;
2016-11-13 18:52:34 +01:00
typedef CacheMap < uint256 , CGovernanceObject * > object_ref_cache_t ;
2016-08-17 09:08:25 +02:00
typedef std : : map < uint256 , int > count_m_t ;
typedef count_m_t : : iterator count_m_it ;
typedef count_m_t : : const_iterator count_m_cit ;
typedef std : : map < uint256 , CGovernanceVote > vote_m_t ;
typedef vote_m_t : : iterator vote_m_it ;
typedef vote_m_t : : const_iterator vote_m_cit ;
2016-11-13 18:52:34 +01:00
typedef CacheMap < uint256 , CGovernanceVote > vote_cache_t ;
2016-08-17 09:08:25 +02:00
2016-11-13 18:52:34 +01:00
typedef CacheMultiMap < uint256 , CGovernanceVote > vote_mcache_t ;
2016-08-17 09:08:25 +02:00
typedef object_m_t : : size_type size_type ;
2016-09-15 08:49:24 +02:00
typedef std : : map < COutPoint , int > txout_m_t ;
typedef txout_m_t : : iterator txout_m_it ;
typedef txout_m_t : : const_iterator txout_m_cit ;
2016-11-13 18:52:34 +01:00
typedef std : : set < uint256 > hash_s_t ;
typedef hash_s_t : : iterator hash_s_it ;
typedef hash_s_t : : const_iterator hash_s_cit ;
2016-04-09 21:57:53 +02:00
private :
2016-11-13 18:52:34 +01:00
static const int MAX_CACHE_SIZE = 1000000 ;
static const std : : string SERIALIZATION_VERSION_STRING ;
2016-04-09 21:57:53 +02:00
// Keep track of current block index
const CBlockIndex * pCurrentBlockIndex ;
2016-04-19 18:51:15 +02:00
int64_t nTimeLastDiff ;
2016-08-17 09:08:25 +02:00
int nCachedBlockHeight ;
2016-04-19 18:51:15 +02:00
2016-08-17 09:08:25 +02:00
// keep track of the scanning errors
object_m_t mapObjects ;
2016-04-09 21:57:53 +02:00
2016-08-17 09:08:25 +02:00
count_m_t mapSeenGovernanceObjects ;
2016-06-08 08:57:16 +02:00
2016-11-13 18:52:34 +01:00
object_ref_cache_t mapVoteToObject ;
vote_cache_t mapInvalidVotes ;
vote_mcache_t mapOrphanVotes ;
2016-04-09 21:57:53 +02:00
2016-09-15 08:49:24 +02:00
txout_m_t mapLastMasternodeTrigger ;
2016-09-05 01:44:10 +02:00
2016-11-13 18:52:34 +01:00
hash_s_t setRequestedObjects ;
hash_s_t setRequestedVotes ;
2016-08-17 09:08:25 +02:00
public :
// critical section to protect the inner data structures
mutable CCriticalSection cs ;
2016-09-12 09:40:00 +02:00
2016-09-05 01:44:10 +02:00
CGovernanceManager ( ) ;
2016-04-09 21:57:53 +02:00
2016-11-13 18:52:34 +01:00
virtual ~ CGovernanceManager ( ) { }
2016-09-12 09:40:00 +02:00
void ClearSeen ( )
{
2016-08-17 09:08:25 +02:00
LOCK ( cs ) ;
2016-05-23 19:53:05 +02:00
mapSeenGovernanceObjects . clear ( ) ;
2016-04-09 21:57:53 +02:00
}
int CountProposalInventoryItems ( )
{
2016-11-13 18:52:34 +01:00
// TODO What is this for ?
return mapSeenGovernanceObjects . size ( ) ;
//return mapSeenGovernanceObjects.size() + mapSeenVotes.size();
2016-04-09 21:57:53 +02:00
}
2016-11-13 18:52:34 +01:00
/**
* This is called by AlreadyHave in main . 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 ) .
*/
bool ConfirmInventoryRequest ( const CInv & inv ) ;
2016-04-14 00:41:40 +02:00
void Sync ( CNode * node , uint256 nProp ) ;
2016-11-13 18:52:34 +01:00
2016-06-08 08:57:16 +02:00
void SyncParentObjectByVote ( CNode * pfrom , const CGovernanceVote & vote ) ;
2016-04-09 21:57:53 +02:00
void ProcessMessage ( CNode * pfrom , std : : string & strCommand , CDataStream & vRecv ) ;
2016-11-13 18:52:34 +01:00
2016-04-09 21:57:53 +02:00
void NewBlock ( ) ;
2016-04-09 22:31:01 +02:00
2016-06-08 08:57:16 +02:00
CGovernanceObject * FindGovernanceObject ( const uint256 & nHash ) ;
2016-08-17 09:08:25 +02:00
2016-11-13 18:52:34 +01:00
std : : vector < CGovernanceVote > GetMatchingVotes ( const uint256 & nParentHash ) ;
2016-08-17 09:08:25 +02:00
std : : vector < CGovernanceObject * > GetAllNewerThan ( int64_t nMoreThanTime ) ;
2016-04-09 22:31:01 +02:00
2016-04-09 21:57:53 +02:00
bool IsBudgetPaymentBlock ( int nBlockHeight ) ;
2016-05-28 12:31:44 +02:00
bool AddGovernanceObject ( CGovernanceObject & govobj ) ;
2016-08-17 09:08:25 +02:00
2016-04-09 21:57:53 +02:00
std : : string GetRequiredPaymentsString ( int nBlockHeight ) ;
2016-11-13 18:52:34 +01:00
2016-08-17 09:08:25 +02:00
void UpdateCachesAndClean ( ) ;
2016-04-09 21:57:53 +02:00
2016-11-13 18:52:34 +01:00
void CheckAndRemove ( ) { UpdateCachesAndClean ( ) ; }
2016-08-17 09:08:25 +02:00
2016-09-12 09:40:00 +02:00
void Clear ( )
{
2016-04-09 21:57:53 +02:00
LOCK ( cs ) ;
2016-08-17 09:08:25 +02:00
LogPrint ( " gobject " , " Governance object manager was cleared \n " ) ;
2016-05-13 18:03:01 +02:00
mapObjects . clear ( ) ;
2016-05-23 19:53:05 +02:00
mapSeenGovernanceObjects . clear ( ) ;
2016-11-13 18:52:34 +01:00
mapVoteToObject . Clear ( ) ;
mapInvalidVotes . Clear ( ) ;
mapOrphanVotes . Clear ( ) ;
2016-09-05 01:44:10 +02:00
mapLastMasternodeTrigger . clear ( ) ;
2016-04-09 21:57:53 +02:00
}
2016-09-12 09:40:00 +02:00
2016-04-09 21:57:53 +02:00
std : : string ToString ( ) const ;
ADD_SERIALIZE_METHODS ;
template < typename Stream , typename Operation >
inline void SerializationOp ( Stream & s , Operation ser_action , int nType , int nVersion ) {
2016-08-17 09:08:25 +02:00
LOCK ( cs ) ;
2016-11-13 18:52:34 +01:00
std : : string strVersion ;
if ( ser_action . ForRead ( ) ) {
READWRITE ( strVersion ) ;
}
else {
strVersion = SERIALIZATION_VERSION_STRING ;
READWRITE ( strVersion ) ;
}
2016-05-23 19:53:05 +02:00
READWRITE ( mapSeenGovernanceObjects ) ;
2016-11-13 18:52:34 +01:00
READWRITE ( mapInvalidVotes ) ;
2016-05-23 19:58:39 +02:00
READWRITE ( mapOrphanVotes ) ;
2016-05-13 18:03:01 +02:00
READWRITE ( mapObjects ) ;
2016-09-05 01:44:10 +02:00
READWRITE ( mapLastMasternodeTrigger ) ;
2016-11-13 18:52:34 +01:00
if ( ser_action . ForRead ( ) & & ( strVersion ! = SERIALIZATION_VERSION_STRING ) ) {
Clear ( ) ;
return ;
}
2016-11-05 17:13:30 +01:00
if ( ser_action . ForRead ( ) ) {
2016-11-13 18:52:34 +01:00
RebuildIndexes ( ) ;
2016-11-05 17:13:30 +01:00
AddCachedTriggers ( ) ;
}
2016-04-09 21:57:53 +02:00
}
void UpdatedBlockTip ( const CBlockIndex * pindex ) ;
2016-09-12 09:40:00 +02:00
int64_t GetLastDiffTime ( ) { return nTimeLastDiff ; }
void UpdateLastDiffTime ( int64_t nTimeIn ) { nTimeLastDiff = nTimeIn ; }
2016-08-17 09:08:25 +02:00
int GetCachedBlockHeight ( ) { return nCachedBlockHeight ; }
// Accessors for thread-safe access to maps
bool HaveObjectForHash ( uint256 nHash ) ;
bool HaveVoteForHash ( uint256 nHash ) ;
bool SerializeObjectForHash ( uint256 nHash , CDataStream & ss ) ;
bool SerializeVoteForHash ( uint256 nHash , CDataStream & ss ) ;
void AddSeenGovernanceObject ( uint256 nHash , int status ) ;
void AddSeenVote ( uint256 nHash , int status ) ;
2016-10-17 20:54:28 +02:00
bool MasternodeRateCheck ( const CTxIn & vin , int nObjectType ) ;
2016-09-05 01:44:10 +02:00
2016-11-13 18:52:34 +01:00
bool ProcessVote ( const CGovernanceVote & vote , CGovernanceException & exception ) {
return ProcessVote ( NULL , vote , exception ) ;
}
void CheckMasternodeOrphanVotes ( ) ;
2016-11-05 17:13:30 +01:00
private :
2016-11-13 18:52:34 +01:00
void RequestGovernanceObject ( CNode * pfrom , const uint256 & nHash ) ;
void AddInvalidVote ( const CGovernanceVote & vote )
{
mapInvalidVotes . Insert ( vote . GetHash ( ) , vote ) ;
}
void AddOrphanVote ( const CGovernanceVote & vote )
{
mapOrphanVotes . Insert ( vote . GetHash ( ) , vote ) ;
}
bool ProcessVote ( CNode * pfrom , const CGovernanceVote & vote , CGovernanceException & exception ) ;
/// Called to indicate a requested object has been received
bool AcceptObjectMessage ( const uint256 & nHash ) ;
/// Called to indicate a requested vote has been received
bool AcceptVoteMessage ( const uint256 & nHash ) ;
static bool AcceptMessage ( const uint256 & nHash , hash_s_t & setHash ) ;
void CheckOrphanVotes ( CNode * pfrom , CGovernanceObject & govobj , CGovernanceException & exception ) ;
void RebuildIndexes ( ) ;
/// Returns MN index, handling the case of index rebuilds
int GetMasternodeIndex ( const CTxIn & masternodeVin ) ;
void RebuildVoteMaps ( ) ;
2016-11-05 17:13:30 +01:00
void AddCachedTriggers ( ) ;
2016-04-09 21:57:53 +02:00
} ;
2016-11-13 18:52:34 +01:00
struct vote_instance_t {
vote_outcome_enum_t eOutcome ;
int64_t nTime ;
vote_instance_t ( vote_outcome_enum_t eOutcomeIn = VOTE_OUTCOME_NONE , int64_t nTimeIn = 0 )
: eOutcome ( eOutcomeIn ) ,
nTime ( nTimeIn )
{ }
ADD_SERIALIZE_METHODS ;
template < typename Stream , typename Operation >
inline void SerializationOp ( Stream & s , Operation ser_action , int nType , int nVersion )
{
int nOutcome = int ( eOutcome ) ;
READWRITE ( nOutcome ) ;
READWRITE ( nTime ) ;
if ( ser_action . ForRead ( ) ) {
eOutcome = vote_outcome_enum_t ( nOutcome ) ;
}
}
} ;
typedef std : : map < int , vote_instance_t > vote_instance_m_t ;
typedef vote_instance_m_t : : iterator vote_instance_m_it ;
typedef vote_instance_m_t : : const_iterator vote_instance_m_cit ;
struct vote_rec_t {
vote_instance_m_t mapInstances ;
ADD_SERIALIZE_METHODS ;
template < typename Stream , typename Operation >
inline void SerializationOp ( Stream & s , Operation ser_action , int nType , int nVersion )
{
READWRITE ( mapInstances ) ;
}
} ;
2016-04-14 03:52:26 +02:00
/**
2016-08-17 09:08:25 +02:00
* Governance Object
2016-04-14 03:52:26 +02:00
*
*/
2016-04-16 19:19:17 +02:00
class CGovernanceObject
2016-04-09 21:57:53 +02:00
{
2016-11-13 18:52:34 +01:00
friend class CGovernanceManager ;
friend class CGovernanceTriggerManager ;
public : // Types
typedef std : : map < int , vote_rec_t > vote_m_t ;
typedef vote_m_t : : iterator vote_m_it ;
typedef vote_m_t : : const_iterator vote_m_cit ;
typedef CacheMultiMap < CTxIn , CGovernanceVote > vote_mcache_t ;
2016-04-09 21:57:53 +02:00
private :
2016-11-13 18:52:34 +01:00
/// critical section to protect the inner data structures
2016-04-09 21:57:53 +02:00
mutable CCriticalSection cs ;
2016-11-13 18:52:34 +01:00
/// Object typecode
2016-08-17 09:08:25 +02:00
int nObjectType ;
2016-05-23 19:53:05 +02:00
2016-11-13 18:52:34 +01:00
/// parent object, 0 is root
uint256 nHashParent ;
/// object revision in the system
int nRevision ;
/// time this object was created
int64_t nTime ;
/// fee-tx
uint256 nCollateralHash ;
/// Data field - can be used for anything
std : : string strData ;
/// Masternode info for signed objects
2016-09-05 01:44:10 +02:00
CTxIn vinMasternode ;
std : : vector < unsigned char > vchSig ;
2016-11-13 18:52:34 +01:00
/// is valid by blockchain
bool fCachedLocalValidity ;
2016-09-15 08:49:24 +02:00
std : : string strLocalValidityError ;
2016-08-17 09:08:25 +02:00
// VARIOUS FLAGS FOR OBJECT / SET VIA MASTERNODE VOTING
2016-11-13 18:52:34 +01:00
/// true == minimum network support has been reached for this object to be funded (doesn't mean it will for sure though)
bool fCachedFunding ;
/// 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)
bool fCachedValid ;
2016-04-19 18:51:15 +02:00
2016-11-13 18:52:34 +01:00
/// true == minimum network support has been reached saying this object should be deleted from the system entirely
bool fCachedDelete ;
/** 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 )
*/
bool fCachedEndorsed ;
/// object was updated and cached values should be updated soon
bool fDirtyCache ;
/// Object is no longer of interest
bool fExpired ;
/// Failed to parse object data
bool fUnparsable ;
vote_m_t mapCurrentMNVotes ;
/// Limited map of votes orphaned by MN
vote_mcache_t mapOrphanVotes ;
CGovernanceObjectVoteFile fileVotes ;
public :
2016-04-17 02:29:41 +02:00
CGovernanceObject ( ) ;
2016-11-13 18:52:34 +01:00
2016-09-17 21:37:48 +02:00
CGovernanceObject ( uint256 nHashParentIn , int nRevisionIn , int64_t nTime , uint256 nCollateralHashIn , std : : string strDataIn ) ;
2016-11-13 18:52:34 +01:00
2016-04-26 13:42:34 +02:00
CGovernanceObject ( const CGovernanceObject & other ) ;
2016-11-13 18:52:34 +01:00
2016-08-17 09:08:25 +02:00
void swap ( CGovernanceObject & first , CGovernanceObject & second ) ; // nothrow
2016-04-26 13:42:34 +02:00
2016-11-13 18:52:34 +01:00
// Public Getter methods
int64_t GetCreationTime ( ) const {
return nTime ;
}
int GetObjectType ( ) const {
return nObjectType ;
}
const uint256 & GetCollateralHash ( ) const {
return nCollateralHash ;
}
const CTxIn & GetMasternodeVin ( ) const {
return vinMasternode ;
}
bool IsSetCachedFunding ( ) const {
return fCachedFunding ;
}
bool IsSetCachedValid ( ) const {
return fCachedValid ;
}
bool IsSetCachedDelete ( ) const {
return fCachedDelete ;
}
bool IsSetCachedEndorsed ( ) const {
return fCachedEndorsed ;
}
bool IsSetDirtyCache ( ) const {
return fDirtyCache ;
}
bool IsSetExpired ( ) const {
return fExpired ;
}
void InvalidateVoteCache ( ) {
fDirtyCache = true ;
}
CGovernanceObjectVoteFile & GetVoteFile ( ) {
return fileVotes ;
}
2016-09-05 01:44:10 +02:00
// Signature related functions
2016-09-15 08:49:24 +02:00
void SetMasternodeInfo ( const CTxIn & vin ) ;
2016-10-22 18:52:14 +02:00
bool Sign ( CKey & keyMasternode , CPubKey & pubKeyMasternode ) ;
bool CheckSignature ( CPubKey & pubKeyMasternode ) ;
2016-09-05 01:44:10 +02:00
2016-08-17 09:08:25 +02:00
// CORE OBJECT FUNCTIONS
2016-06-08 08:57:16 +02:00
2016-08-17 09:08:25 +02:00
bool IsValidLocally ( const CBlockIndex * pindex , std : : string & strError , bool fCheckCollateral ) ;
2016-09-05 01:44:10 +02:00
2016-11-11 21:47:04 +01:00
bool IsValidLocally ( const CBlockIndex * pindex , std : : string & strError , bool & fMissingMasternode , bool fCheckCollateral ) ;
2016-09-05 01:44:10 +02:00
/// Check the collateral transaction for the budget proposal/finalized budget
bool IsCollateralValid ( std : : string & strError ) ;
2016-08-17 09:08:25 +02:00
void UpdateLocalValidity ( const CBlockIndex * pCurrentBlockIndex ) ;
2016-11-13 18:52:34 +01:00
2016-08-17 09:08:25 +02:00
void UpdateSentinelVariables ( const CBlockIndex * pCurrentBlockIndex ) ;
2016-11-13 18:52:34 +01:00
2016-08-17 09:08:25 +02:00
int GetObjectSubtype ( ) ;
2016-04-26 06:08:36 +02:00
2016-09-05 01:44:10 +02:00
CAmount GetMinCollateralFee ( ) ;
2016-08-17 09:08:25 +02:00
UniValue GetJSONObject ( ) ;
2016-04-17 02:29:41 +02:00
2016-08-17 09:08:25 +02:00
void Relay ( ) ;
2016-11-13 18:52:34 +01:00
2016-08-17 09:08:25 +02:00
uint256 GetHash ( ) ;
2016-04-17 02:29:41 +02:00
2016-08-17 09:08:25 +02:00
// GET VOTE COUNT FOR SIGNAL
2016-04-26 06:08:36 +02:00
2016-11-13 18:52:34 +01:00
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 ;
2016-04-17 02:29:41 +02:00
2016-09-12 09:40:00 +02:00
// FUNCTIONS FOR DEALING WITH DATA STRING
2016-05-13 18:03:01 +02:00
2016-08-17 09:08:25 +02:00
std : : string GetDataAsHex ( ) ;
std : : string GetDataAsString ( ) ;
2016-05-13 18:03:01 +02:00
2016-08-17 09:08:25 +02:00
// SERIALIZER
2016-04-16 19:19:17 +02:00
2016-04-09 21:57:53 +02:00
ADD_SERIALIZE_METHODS ;
template < typename Stream , typename Operation >
2016-04-17 02:29:41 +02:00
inline void SerializationOp ( Stream & s , Operation ser_action , int nType , int nVersion )
{
2016-05-27 00:03:37 +02:00
// SERIALIZE DATA FOR SAVING/LOADING OR NETWORK FUNCTIONS
2016-04-26 06:08:36 +02:00
READWRITE ( nHashParent ) ;
READWRITE ( nRevision ) ;
2016-04-09 21:57:53 +02:00
READWRITE ( nTime ) ;
2016-08-17 09:08:25 +02:00
READWRITE ( nCollateralHash ) ;
2016-09-17 21:37:48 +02:00
READWRITE ( LIMITED_STRING ( strData , MAX_GOVERNANCE_OBJECT_DATA_SIZE ) ) ;
2016-08-17 09:08:25 +02:00
READWRITE ( nObjectType ) ;
2016-09-05 01:44:10 +02:00
READWRITE ( vinMasternode ) ;
READWRITE ( vchSig ) ;
2016-11-13 18:52:34 +01:00
if ( nType & SER_DISK ) {
// Only include these for the disk file format
LogPrint ( " gobject " , " CGovernanceObject::SerializationOp Reading/writing votes from/to disk \n " ) ;
READWRITE ( mapCurrentMNVotes ) ;
READWRITE ( fileVotes ) ;
LogPrint ( " gobject " , " CGovernanceObject::SerializationOp hash = %s, vote count = %d \n " , GetHash ( ) . ToString ( ) , fileVotes . GetVoteCount ( ) ) ;
}
2016-06-10 07:16:32 +02:00
// AFTER DESERIALIZATION OCCURS, CACHED VARIABLES MUST BE CALCULATED MANUALLY
2016-04-09 21:57:53 +02:00
}
2016-09-05 01:44:10 +02:00
2016-09-08 13:40:19 +02:00
private :
2016-09-12 09:40:00 +02:00
// FUNCTIONS FOR DEALING WITH DATA STRING
2016-09-08 13:40:19 +02:00
void LoadData ( ) ;
void GetData ( UniValue & objResult ) ;
2016-11-13 18:52:34 +01:00
bool ProcessVote ( CNode * pfrom ,
const CGovernanceVote & vote ,
CGovernanceException & exception ) ;
void RebuildVoteMap ( ) ;
/// Called when MN's which have voted on this object have been removed
void ClearMasternodeVotes ( ) ;
void CheckOrphanVotes ( ) ;
2016-04-09 21:57:53 +02:00
} ;
# endif