6 #ifndef PIVX_MASTERNODEMAN_H
7 #define PIVX_MASTERNODEMAN_H
18 #define MASTERNODES_REQUEST_SECONDS (60 * 60)
21 static const unsigned int CACHED_BLOCK_HASHES = 200;
105 READWRITE(obj.mAskedUsForMasternodeList);
106 READWRITE(obj.mWeAskedForMasternodeList);
107 READWRITE(obj.mWeAskedForMasternodeListEntry);
110 READWRITE(obj.mapSeenMasternodeBroadcast);
150 std::vector<std::pair<MasternodeRef, int>>
GetMnScores(
int nLast)
const;
153 std::vector<std::pair<int64_t, MasternodeRef>>
GetMasternodeRanks(
int nBlockHeight)
const;
The block chain is a tree shaped structure starting with the genesis block at the root,...
Access to the MN database (mncache.dat)
bool Write(const CMasternodeMan &mnodemanToSave)
ReadResult Read(CMasternodeMan &mnodemanToLoad)
std::string strMagicMessage
std::map< uint256, CMasternodeBroadcast > mapSeenMasternodeBroadcast
std::map< CNetAddr, int64_t > mAskedUsForMasternodeList
void UpdateMasternodeList(CMasternodeBroadcast &mnb)
Update masternode list and maps using provided CMasternodeBroadcast.
std::map< CNetAddr, int64_t > mWeAskedForMasternodeList
int CheckAndRemove(bool forceExpiredRemoval=false)
Check all Masternodes and remove inactive. Return the total masternode count.
int CountEnabled(bool only_legacy=false) const
bool CheckInputs(CMasternodeBroadcast &mnb, int nChainHeight, int &nDoS)
void CheckSpentCollaterals(const std::vector< CTransactionRef > &vtx)
Check all transactions in a block, for spent masternode collateral outpoints (marking them as spent)
int ProcessGetMNList(CNode *pfrom, CTxIn &vin)
RecursiveMutex cs_process_message
std::vector< std::pair< int64_t, MasternodeRef > > GetMasternodeRanks(int nBlockHeight) const
std::vector< std::pair< MasternodeRef, int > > GetMnScores(int nLast) const
vector of pairs <masternode winner, height>
void AskForMN(CNode *pnode, const CTxIn &vin)
Ask (source) node for mnb.
void CacheBlockHash(const CBlockIndex *pindex)
uint256 GetHashAtHeight(int nHeight) const
std::map< COutPoint, MasternodeRef > mapMasternodes
MasternodeRef GetNextMasternodeInQueueForPayment(int nBlockHeight, bool fFilterSigTime, int &nCount, const CBlockIndex *pChainTip=nullptr) const
Find an entry in the masternode list that is next to be paid.
std::atomic< int > nBestHeight
bool RequestMnList(CNode *pnode)
void SetBestHeight(int height)
int ProcessMNPing(CNode *pfrom, CMasternodePing &mnp)
int GetBestHeight() const
int64_t GetLastPaid(const MasternodeRef &mn, int count_enabled, const CBlockIndex *BlockReading) const
Get the time a masternode was last paid.
CMasternodeMan::MNsInfo getMNsInfo() const
std::string ToString() const
int GetMasternodeRank(const CTxIn &vin, int64_t nBlockHeight) const
SERIALIZE_METHODS(CMasternodeMan, obj)
bool ProcessMessage(CNode *pfrom, std::string &strCommand, CDataStream &vRecv, int &dosScore)
void Remove(const COutPoint &collateralOut)
bool Add(CMasternode &mn)
Add an entry.
int64_t SecondsSincePayment(const MasternodeRef &mn, int count_enabled, const CBlockIndex *BlockReading) const
CyclingVector< uint256 > cvLastBlockHashes
std::map< COutPoint, int64_t > mWeAskedForMasternodeListEntry
void Clear()
Clear Masternode vector.
int ProcessMNBroadcast(CNode *pfrom, CMasternodeBroadcast &mnb)
uint256 GetBlockHashToPing() const
bool IsWithinDepth(const uint256 &nHash, int depth) const
std::map< uint256, CMasternodePing > mapSeenMasternodePing
CMasternode * Find(const COutPoint &collateralOut)
Find an entry.
void BroadcastInvMN(CMasternode *mn, CNode *pfrom)
MasternodeRef GetCurrentMasterNode(const uint256 &hash) const
Get the winner for this block hash.
int ProcessMessageInner(CNode *pfrom, std::string &strCommand, CDataStream &vRecv)
void UncacheBlockHash(const CBlockIndex *pindex)
std::vector< uint256 > GetCachedBlocks() const
Information about a peer.
An outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
An input of a transaction.
std::vector< T > GetCache() const
std::shared_ptr< CMasternode > MasternodeRef
CMasternodeMan mnodeman
Masternode manager.
CActiveMasternode activeMasternode
Keep track of the active Masternode.
void ThreadCheckMasternodes()