2018-11-06 09:54:23 +01:00
|
|
|
// Copyright (c) 2014-2018 The Dash Core developers
|
2014-12-09 02:17:57 +01:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2016-08-05 21:49:45 +02:00
|
|
|
|
2014-12-09 02:17:57 +01:00
|
|
|
#ifndef ACTIVEMASTERNODE_H
|
|
|
|
#define ACTIVEMASTERNODE_H
|
|
|
|
|
2017-12-01 19:53:34 +01:00
|
|
|
#include "chainparams.h"
|
2014-12-09 02:17:57 +01:00
|
|
|
#include "key.h"
|
2017-12-01 19:53:34 +01:00
|
|
|
#include "net.h"
|
|
|
|
#include "primitives/transaction.h"
|
2018-02-15 14:33:04 +01:00
|
|
|
#include "validationinterface.h"
|
|
|
|
|
|
|
|
#include "evo/deterministicmns.h"
|
2018-11-06 09:54:23 +01:00
|
|
|
#include "evo/providertx.h"
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2018-08-11 21:55:56 +02:00
|
|
|
struct CActiveMasternodeInfo;
|
2018-02-15 14:33:04 +01:00
|
|
|
class CActiveDeterministicMasternodeManager;
|
2016-08-05 21:49:45 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-08-11 21:55:56 +02:00
|
|
|
extern CActiveMasternodeInfo activeMasternodeInfo;
|
2018-02-15 14:33:04 +01:00
|
|
|
extern CActiveDeterministicMasternodeManager* activeMasternodeManager;
|
2018-08-11 21:55:56 +02:00
|
|
|
|
|
|
|
struct CActiveMasternodeInfo {
|
|
|
|
// Keys for the active Masternode
|
2018-10-21 21:45:16 +02:00
|
|
|
std::unique_ptr<CBLSPublicKey> blsPubKeyOperator;
|
|
|
|
std::unique_ptr<CBLSSecretKey> blsKeyOperator;
|
2018-08-11 21:55:56 +02:00
|
|
|
|
|
|
|
// Initialized while registering Masternode
|
2018-11-23 16:33:45 +01:00
|
|
|
uint256 proTxHash;
|
2018-08-11 21:55:56 +02:00
|
|
|
COutPoint outpoint;
|
|
|
|
CService service;
|
|
|
|
};
|
2015-07-17 12:26:24 +02:00
|
|
|
|
2018-02-15 14:33:04 +01:00
|
|
|
|
|
|
|
class CActiveDeterministicMasternodeManager : public CValidationInterface
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum masternode_state_t {
|
|
|
|
MASTERNODE_WAITING_FOR_PROTX,
|
|
|
|
MASTERNODE_POSE_BANNED,
|
|
|
|
MASTERNODE_REMOVED,
|
2018-12-10 06:04:13 +01:00
|
|
|
MASTERNODE_OPERATOR_KEY_CHANGED,
|
2018-02-15 14:33:04 +01:00
|
|
|
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;
|
|
|
|
|
2019-01-03 10:17:43 +01:00
|
|
|
static bool IsValidNetAddr(CService addrIn);
|
2016-10-17 20:54:28 +02:00
|
|
|
|
2015-07-14 07:25:07 +02:00
|
|
|
private:
|
2019-01-03 10:17:43 +01:00
|
|
|
bool GetLocalAddress(CService& addrRet);
|
2014-12-09 02:17:57 +01:00
|
|
|
};
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
#endif
|