// Copyright (c) 2014-2018 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 ACTIVEMASTERNODE_H #define ACTIVEMASTERNODE_H #include "chainparams.h" #include "key.h" #include "net.h" #include "primitives/transaction.h" #include "validationinterface.h" #include "evo/deterministicmns.h" #include "evo/providertx.h" struct CActiveMasternodeInfo; class CActiveMasternodeManager; static const int ACTIVE_MASTERNODE_INITIAL = 0; // initial state static const int ACTIVE_MASTERNODE_SYNC_IN_PROCESS = 1; static const int ACTIVE_MASTERNODE_INPUT_TOO_NEW = 2; static const int ACTIVE_MASTERNODE_NOT_CAPABLE = 3; static const int ACTIVE_MASTERNODE_STARTED = 4; extern CActiveMasternodeInfo activeMasternodeInfo; extern CActiveMasternodeManager* activeMasternodeManager; struct CActiveMasternodeInfo { // Keys for the active Masternode std::unique_ptr blsPubKeyOperator; std::unique_ptr blsKeyOperator; // Initialized while registering Masternode uint256 proTxHash; COutPoint outpoint; CService service; }; class CActiveMasternodeManager : public CValidationInterface { public: enum masternode_state_t { MASTERNODE_WAITING_FOR_PROTX, MASTERNODE_POSE_BANNED, MASTERNODE_REMOVED, MASTERNODE_OPERATOR_KEY_CHANGED, MASTERNODE_READY, MASTERNODE_ERROR, }; private: CDeterministicMNCPtr mnListEntry; masternode_state_t state{MASTERNODE_WAITING_FOR_PROTX}; std::string strError; public: virtual void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload); void Init(); CDeterministicMNCPtr GetDMN() const { return mnListEntry; } std::string GetStateString() const; std::string GetStatus() const; static bool IsValidNetAddr(CService addrIn); private: bool GetLocalAddress(CService& addrRet); }; #endif