forked from lazyboozer/Desire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivemasternode.h
85 lines (64 loc) · 2.13 KB
/
activemasternode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2014-2017 The Desire 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(CConnman& connman);
// sentinel ping data
int64_t nSentinelPingTime;
uint32_t nSentinelVersion;
public:
// Keys for the active Masternode
CPubKey pubKeyMasternode;
CKey keyMasternode;
// Initialized while registering Masternode
COutPoint outpoint;
CService service;
int nState; // should be one of ACTIVE_MASTERNODE_XXXX
std::string strNotCapableReason;
CActiveMasternode()
: eType(MASTERNODE_UNKNOWN),
fPingerEnabled(false),
pubKeyMasternode(),
keyMasternode(),
outpoint(),
service(),
nState(ACTIVE_MASTERNODE_INITIAL)
{}
/// Manage state of active Masternode
void ManageState(CConnman& connman);
std::string GetStateString() const;
std::string GetStatus() const;
std::string GetTypeString() const;
bool UpdateSentinelPing(int version);
private:
void ManageStateInitial(CConnman& connman);
void ManageStateRemote();
void ManageStateLocal(CConnman& connman);
};
#endif