2016-08-05 21:49:45 +02:00
|
|
|
// Copyright (c) 2014-2016 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
|
|
|
|
|
|
|
|
#include "net.h"
|
|
|
|
#include "key.h"
|
2016-02-02 16:28:56 +01:00
|
|
|
#include "wallet/wallet.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
|
|
|
|
{
|
2015-07-14 07:25:07 +02:00
|
|
|
private:
|
|
|
|
// critical section to protect the inner data structures
|
|
|
|
mutable CCriticalSection cs;
|
|
|
|
|
|
|
|
/// Ping Masternode
|
2016-09-05 18:09:25 +02:00
|
|
|
bool SendMasternodePing(std::string& strErrorRet);
|
2015-07-14 07:25:07 +02:00
|
|
|
|
2014-12-09 02:17:57 +01:00
|
|
|
public:
|
2016-03-15 00:16:29 +01:00
|
|
|
// Initialized by init.cpp
|
2016-08-05 21:49:45 +02:00
|
|
|
std::string strMasterNodeAddr;
|
|
|
|
// 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
|
|
|
|
CTxIn vin;
|
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
|
|
|
|
2016-08-05 21:49:45 +02:00
|
|
|
CActiveMasternode() : 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
|
|
|
|
void ManageState();
|
2014-12-06 20:41:53 +01:00
|
|
|
|
2016-08-05 21:49:45 +02:00
|
|
|
std::string GetStatus();
|
2014-12-06 20:41:53 +01:00
|
|
|
|
2015-07-14 07:25:07 +02:00
|
|
|
/// Enable cold wallet mode (run a Masternode with no funds)
|
2016-09-05 18:09:25 +02:00
|
|
|
bool EnableRemoteMasterNode(CTxIn& vinNew, CService& serviceNew);
|
2014-12-09 02:17:57 +01:00
|
|
|
};
|
|
|
|
|
2014-12-06 20:41:53 +01:00
|
|
|
#endif
|