mirror of
https://github.com/dashpay/dash.git
synced 2024-12-30 14:25:53 +01:00
f95aae2b30
* Remove CActiveLegacyMasternodeManager * Remove sentinelping RPC * Remove unused P2P messages and inv types There are still places where these are used in the code. The next commits will clean these up. * Remove MNB/MNP/MNVERIFY related code from masternode(man).h/cpp * Remove all legacy code regarding block MN payee voting * Remove MASTERNODE_SYNC_LIST and MASTERNODE_SYNC_MNW states Also replace all uses of IsMasternodeListSynced and IsWinnersListSynced with IsBlockchainSynced. * Remove unsupported masternode RPCs * Remove UpdateLastPaid methods * Remove duplicate deterministicmns.h include * Remove masternode.conf support * Remove legacy MN lists support from masternode list GUI * Remove unnecessary AskForMN call * Remove compatibility code in CPrivateSendQueue::GetSignatureHash * Don't add locally calculated MN payee in case GetBlockTxOuts failed This is not valid in DIP3 mode * Remove check for IsDeterministicMNsSporkActive in "masternode status" * Move CMasternode::IsValidNetAddr to CActiveDeterministicMasternodeManager * Remove use of CMasternode::CheckCollateral in governance code * Remove uses of MASTERNODE_SENTINEL_PING_MAX_SECONDS/MASTERNODE_SENTINEL_PING_MAX_SECONDS * Remove support for "-masternodeprivkey" * Remove pre-DIP3 vote cleanup * Remove compatibility code for quorumModifierHash/masternodeProTxHash * Remove check for invalid nBlockHeight in CMasternodePayments::GetBlockTxOuts ...and let it crash instead. We expect this method to be called with the correct height now (after DIP3 was fully deployed). * Remove ECDSA based Sign/CheckSignature from CGovernanceObject Only masternodes sign governance objects, so there is no need for ECDSA support here anymore. * Always add superblock and MN reward payments into new block * Always check block payees (except if fLiteMode==true) * Always allow superblock and MN payees in same block * Remove/Fix a few references to masternode.conf and related stuff Also delete guide-startmany.md and masternode_conf.md * Implement NotifyMasternodeListChanged signal and call governance maintenance * Remove non-DIP3 code path from CMasternodeMan::Find * Remove remaining unused code from CMasternode/CMasternodeMan * Always load governance.dat on startup * Mine an empty block instead of incrementing nHeight from chain tip in miner tests This test is crashing otherwise in GetBlockTxOuts as it tries to access a previous block that is not existing. * Skip MN payments verification on historical blocks (pre-DIP3 blocks) Even though DIP3 was active on BIP9 level, the spork was not active yet at that point meaning that payments were not enforced at that time. * Remove unused state and CollateralStatus enums * Unconditionally return false from IsBlockPayeeValid when IsTransactionValid returns false IsTransactionValid already handles the case where IsDIP3Active() returns false, making it return true. * Add override keyword to CDSNotificationInterface::NotifyMasternodeListChanged * Fix help for masternodelist status (POSE_BANNED and no OUTPOINT_SPENT)
102 lines
2.9 KiB
C++
102 lines
2.9 KiB
C++
// Copyright (c) 2014-2017 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.
|
|
|
|
#ifndef MASTERNODE_H
|
|
#define MASTERNODE_H
|
|
|
|
#include "key.h"
|
|
#include "validation.h"
|
|
#include "spork.h"
|
|
#include "bls/bls.h"
|
|
|
|
#include "evo/deterministicmns.h"
|
|
|
|
class CMasternode;
|
|
class CConnman;
|
|
|
|
static const int MASTERNODE_MAX_MIXING_TXES = 5;
|
|
|
|
struct masternode_info_t
|
|
{
|
|
// Note: all these constructors can be removed once C++14 is enabled.
|
|
// (in C++11 the member initializers wrongly disqualify this as an aggregate)
|
|
masternode_info_t() = default;
|
|
masternode_info_t(masternode_info_t const&) = default;
|
|
|
|
// only called when the network is in legacy MN list mode
|
|
masternode_info_t(COutPoint const& outpnt) :
|
|
outpoint{outpnt}
|
|
{}
|
|
|
|
COutPoint outpoint{};
|
|
|
|
int64_t nLastDsq = 0; //the dsq count from the last dsq broadcast of this node
|
|
bool fInfoValid = false; //* not in CMN
|
|
};
|
|
|
|
//
|
|
// The Masternode Class. For managing the Darksend process. It contains the input of the 1000DRK, signature to prove
|
|
// it's the one who own that ip address and code for calculating the payment election.
|
|
//
|
|
class CMasternode : public masternode_info_t
|
|
{
|
|
private:
|
|
// critical section to protect the inner data structures
|
|
mutable CCriticalSection cs;
|
|
|
|
public:
|
|
int nMixingTxCount{};
|
|
|
|
// KEEP TRACK OF GOVERNANCE ITEMS EACH MASTERNODE HAS VOTE UPON FOR RECALCULATION
|
|
std::map<uint256, int> mapGovernanceObjectsVotedOn;
|
|
|
|
CMasternode();
|
|
CMasternode(const CMasternode& other);
|
|
CMasternode(const uint256 &proTxHash, const CDeterministicMNCPtr& dmn);
|
|
|
|
ADD_SERIALIZE_METHODS;
|
|
|
|
template <typename Stream, typename Operation>
|
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
|
LOCK(cs);
|
|
READWRITE(outpoint);
|
|
READWRITE(nLastDsq);
|
|
READWRITE(nMixingTxCount);
|
|
READWRITE(mapGovernanceObjectsVotedOn);
|
|
}
|
|
|
|
bool IsValidForMixingTxes() const
|
|
{
|
|
return nMixingTxCount <= MASTERNODE_MAX_MIXING_TXES;
|
|
}
|
|
|
|
masternode_info_t GetInfo() const;
|
|
|
|
// KEEP TRACK OF EACH GOVERNANCE ITEM INCASE THIS NODE GOES OFFLINE, SO WE CAN RECALC THEIR STATUS
|
|
void AddGovernanceVote(uint256 nGovernanceObjectHash);
|
|
// RECALCULATE CACHED STATUS FLAGS FOR ALL AFFECTED OBJECTS
|
|
void FlagGovernanceItemsAsDirty();
|
|
|
|
void RemoveGovernanceObject(uint256 nGovernanceObjectHash);
|
|
|
|
CMasternode& operator=(CMasternode const& from)
|
|
{
|
|
static_cast<masternode_info_t&>(*this)=from;
|
|
nMixingTxCount = from.nMixingTxCount;
|
|
mapGovernanceObjectsVotedOn = from.mapGovernanceObjectsVotedOn;
|
|
return *this;
|
|
}
|
|
};
|
|
|
|
inline bool operator==(const CMasternode& a, const CMasternode& b)
|
|
{
|
|
return a.outpoint == b.outpoint;
|
|
}
|
|
inline bool operator!=(const CMasternode& a, const CMasternode& b)
|
|
{
|
|
return !(a.outpoint == b.outpoint);
|
|
}
|
|
|
|
#endif
|