2016-12-20 14:26:45 +01:00
|
|
|
// Copyright (c) 2014-2017 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"
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2016-08-05 21:49:45 +02:00
|
|
|
class CActiveMasternode;
|
|
|
|
|
|
|
|
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 CActiveMasternode activeMasternode;
|
2015-07-17 12:26:24 +02:00
|
|
|
|
2015-03-05 09:10:15 +01:00
|
|
|
// Responsible for activating the Masternode and pinging the network
|
2014-12-09 02:17:57 +01:00
|
|
|
class CActiveMasternode
|
|
|
|
{
|
2016-10-17 20:54:28 +02:00
|
|
|
public:
|
|
|
|
enum masternode_type_enum_t {
|
|
|
|
MASTERNODE_UNKNOWN = 0,
|
2017-11-01 16:11:39 +01:00
|
|
|
MASTERNODE_REMOTE = 1
|
2016-10-17 20:54:28 +02:00
|
|
|
};
|
|
|
|
|
2015-07-14 07:25:07 +02:00
|
|
|
private:
|
|
|
|
// critical section to protect the inner data structures
|
|
|
|
mutable CCriticalSection cs;
|
|
|
|
|
2016-10-17 20:54:28 +02:00
|
|
|
masternode_type_enum_t eType;
|
|
|
|
|
|
|
|
bool fPingerEnabled;
|
|
|
|
|
2015-07-14 07:25:07 +02:00
|
|
|
/// Ping Masternode
|
2017-09-19 16:51:38 +02:00
|
|
|
bool SendMasternodePing(CConnman& connman);
|
2015-07-14 07:25:07 +02:00
|
|
|
|
2017-07-04 19:31:57 +02:00
|
|
|
// sentinel ping data
|
|
|
|
int64_t nSentinelPingTime;
|
|
|
|
uint32_t nSentinelVersion;
|
|
|
|
|
2014-12-09 02:17:57 +01:00
|
|
|
public:
|
2016-08-05 21:49:45 +02:00
|
|
|
// Keys for the active Masternode
|
2016-03-15 00:16:29 +01:00
|
|
|
CPubKey pubKeyMasternode;
|
2016-07-15 08:36:00 +02:00
|
|
|
CKey keyMasternode;
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2016-03-15 00:16:29 +01:00
|
|
|
// Initialized while registering Masternode
|
2017-09-11 16:13:48 +02:00
|
|
|
COutPoint outpoint;
|
2014-12-06 20:41:53 +01:00
|
|
|
CService service;
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2016-08-05 21:49:45 +02:00
|
|
|
int nState; // should be one of ACTIVE_MASTERNODE_XXXX
|
|
|
|
std::string strNotCapableReason;
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2017-07-04 19:31:57 +02:00
|
|
|
|
2016-10-17 20:54:28 +02:00
|
|
|
CActiveMasternode()
|
|
|
|
: eType(MASTERNODE_UNKNOWN),
|
|
|
|
fPingerEnabled(false),
|
2016-12-24 03:49:13 +01:00
|
|
|
pubKeyMasternode(),
|
|
|
|
keyMasternode(),
|
2017-09-11 16:13:48 +02:00
|
|
|
outpoint(),
|
2016-12-24 03:49:13 +01:00
|
|
|
service(),
|
2016-10-17 20:54:28 +02:00
|
|
|
nState(ACTIVE_MASTERNODE_INITIAL)
|
|
|
|
{}
|
2014-12-09 02:17:57 +01:00
|
|
|
|
2016-08-05 21:49:45 +02:00
|
|
|
/// Manage state of active Masternode
|
2017-09-19 16:51:38 +02:00
|
|
|
void ManageState(CConnman& connman);
|
2014-12-06 20:41:53 +01:00
|
|
|
|
2016-10-26 23:21:39 +02:00
|
|
|
std::string GetStateString() const;
|
|
|
|
std::string GetStatus() const;
|
|
|
|
std::string GetTypeString() const;
|
2016-10-17 20:54:28 +02:00
|
|
|
|
2017-07-04 19:31:57 +02:00
|
|
|
bool UpdateSentinelPing(int version);
|
|
|
|
|
2016-10-17 20:54:28 +02:00
|
|
|
private:
|
2017-09-19 16:51:38 +02:00
|
|
|
void ManageStateInitial(CConnman& connman);
|
2016-10-17 20:54:28 +02:00
|
|
|
void ManageStateRemote();
|
2014-12-09 02:17:57 +01:00
|
|
|
};
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
#endif
|