neobytes/src/activemasternode.h
UdjinM6 70b374062b [WIP] Few mn list sync changes (#1223)
* Few mn list sync changes:
- add more mn states
- only remove spent
- send mn ping in addition to mn announce on sync
- manage mn announces more carefully
- expire mns created from broadcasts with invalid ping
- old fWaitForPing logic for old nodes, should be helpful during migration period

This also adjusts active mn auto-start logic accordingly.
2016-12-24 06:49:13 +04:00

79 lines
1.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 ACTIVEMASTERNODE_H
#define ACTIVEMASTERNODE_H
#include "net.h"
#include "key.h"
#include "wallet/wallet.h"
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;
// Responsible for activating the Masternode and pinging the network
class CActiveMasternode
{
public:
enum masternode_type_enum_t {
MASTERNODE_UNKNOWN = 0,
MASTERNODE_REMOTE = 1,
MASTERNODE_LOCAL = 2
};
private:
// critical section to protect the inner data structures
mutable CCriticalSection cs;
masternode_type_enum_t eType;
bool fPingerEnabled;
/// Ping Masternode
bool SendMasternodePing();
public:
// Keys for the active Masternode
CPubKey pubKeyMasternode;
CKey keyMasternode;
// Initialized while registering Masternode
CTxIn vin;
CService service;
int nState; // should be one of ACTIVE_MASTERNODE_XXXX
std::string strNotCapableReason;
CActiveMasternode()
: eType(MASTERNODE_UNKNOWN),
fPingerEnabled(false),
pubKeyMasternode(),
keyMasternode(),
vin(),
service(),
nState(ACTIVE_MASTERNODE_INITIAL)
{}
/// Manage state of active Masternode
void ManageState();
std::string GetStateString() const;
std::string GetStatus() const;
std::string GetTypeString() const;
private:
void ManageStateInitial();
void ManageStateRemote();
void ManageStateLocal();
};
#endif