mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
Slightly refactor masternode statuses:
- better names (MASTERNODE_INITIAL was defined twice before that) - move to proper header
This commit is contained in:
parent
b6001065ae
commit
33ee068d6a
@ -19,12 +19,12 @@ void CActiveMasternode::ManageStatus()
|
|||||||
|
|
||||||
//need correct blocks to send ping
|
//need correct blocks to send ping
|
||||||
if(IsInitialBlockDownload()) {
|
if(IsInitialBlockDownload()) {
|
||||||
status = MASTERNODE_SYNC_IN_PROCESS;
|
status = ACTIVE_MASTERNODE_SYNC_IN_PROCESS;
|
||||||
LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start Masternode.\n");
|
LogPrintf("CActiveMasternode::ManageStatus() - Sync in progress. Must wait until sync is complete to start Masternode.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status == MASTERNODE_INITIAL || status == MASTERNODE_SYNC_IN_PROCESS) {
|
if(status == ACTIVE_MASTERNODE_INITIAL || status == ACTIVE_MASTERNODE_SYNC_IN_PROCESS) {
|
||||||
CMasternode *pmn;
|
CMasternode *pmn;
|
||||||
pmn = mnodeman.Find(pubKeyMasternode);
|
pmn = mnodeman.Find(pubKeyMasternode);
|
||||||
if(pmn != NULL) {
|
if(pmn != NULL) {
|
||||||
@ -33,10 +33,10 @@ void CActiveMasternode::ManageStatus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status != MASTERNODE_STARTED) {
|
if(status != ACTIVE_MASTERNODE_STARTED) {
|
||||||
|
|
||||||
// Set defaults
|
// Set defaults
|
||||||
status = MASTERNODE_NOT_CAPABLE;
|
status = ACTIVE_MASTERNODE_NOT_CAPABLE;
|
||||||
notCapableReason = "";
|
notCapableReason = "";
|
||||||
|
|
||||||
if(strMasterNodeAddr.empty()) {
|
if(strMasterNodeAddr.empty()) {
|
||||||
@ -86,7 +86,7 @@ void CActiveMasternode::ManageStatus()
|
|||||||
notCapableReason = "Input must have least " + boost::lexical_cast<string>(MASTERNODE_MIN_CONFIRMATIONS) +
|
notCapableReason = "Input must have least " + boost::lexical_cast<string>(MASTERNODE_MIN_CONFIRMATIONS) +
|
||||||
" confirmations - " + boost::lexical_cast<string>(GetInputAge(vin)) + " confirmations";
|
" confirmations - " + boost::lexical_cast<string>(GetInputAge(vin)) + " confirmations";
|
||||||
LogPrintf("CActiveMasternode::ManageStatus() - %s\n", notCapableReason);
|
LogPrintf("CActiveMasternode::ManageStatus() - %s\n", notCapableReason);
|
||||||
status = MASTERNODE_INPUT_TOO_NEW;
|
status = ACTIVE_MASTERNODE_INPUT_TOO_NEW;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ void CActiveMasternode::ManageStatus()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LogPrintf("CActiveMasternode::ManageStatus() - Is capable master node!\n");
|
LogPrintf("CActiveMasternode::ManageStatus() - Is capable master node!\n");
|
||||||
status = MASTERNODE_STARTED;
|
status = ACTIVE_MASTERNODE_STARTED;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -128,17 +128,17 @@ void CActiveMasternode::ManageStatus()
|
|||||||
|
|
||||||
std::string CActiveMasternode::GetStatus() {
|
std::string CActiveMasternode::GetStatus() {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case MASTERNODE_INITIAL: return "node just started, not yet activated";
|
case ACTIVE_MASTERNODE_INITIAL: return "node just started, not yet activated";
|
||||||
case MASTERNODE_SYNC_IN_PROCESS: return "sync in process. Must wait until client is synced to start";
|
case ACTIVE_MASTERNODE_SYNC_IN_PROCESS: return "sync in process. Must wait until client is synced to start";
|
||||||
case MASTERNODE_INPUT_TOO_NEW: return "masternode input must have at least 15 confirmations";
|
case ACTIVE_MASTERNODE_INPUT_TOO_NEW: return "masternode input must have at least 15 confirmations";
|
||||||
case MASTERNODE_NOT_CAPABLE: return "not capable masternode: " + notCapableReason;
|
case ACTIVE_MASTERNODE_NOT_CAPABLE: return "not capable masternode: " + notCapableReason;
|
||||||
case MASTERNODE_STARTED: return "masternode successfully started";
|
case ACTIVE_MASTERNODE_STARTED: return "masternode successfully started";
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CActiveMasternode::SendMasternodePing(std::string& errorMessage) {
|
bool CActiveMasternode::SendMasternodePing(std::string& errorMessage) {
|
||||||
if(status != MASTERNODE_STARTED) {
|
if(status != ACTIVE_MASTERNODE_STARTED) {
|
||||||
errorMessage = "Masternode is not in a running status";
|
errorMessage = "Masternode is not in a running status";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ bool CActiveMasternode::SendMasternodePing(std::string& errorMessage) {
|
|||||||
{
|
{
|
||||||
// Seems like we are trying to send a ping while the Masternode is not registered in the network
|
// Seems like we are trying to send a ping while the Masternode is not registered in the network
|
||||||
errorMessage = "Darksend Masternode List doesn't include our Masternode, shutting down Masternode pinging service! " + vin.ToString();
|
errorMessage = "Darksend Masternode List doesn't include our Masternode, shutting down Masternode pinging service! " + vin.ToString();
|
||||||
status = MASTERNODE_NOT_CAPABLE;
|
status = ACTIVE_MASTERNODE_NOT_CAPABLE;
|
||||||
notCapableReason = errorMessage;
|
notCapableReason = errorMessage;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ bool CActiveMasternode::EnableHotColdMasterNode(CTxIn& newVin, CService& newServ
|
|||||||
{
|
{
|
||||||
if(!fMasterNode) return false;
|
if(!fMasterNode) return false;
|
||||||
|
|
||||||
status = MASTERNODE_STARTED;
|
status = ACTIVE_MASTERNODE_STARTED;
|
||||||
|
|
||||||
//The values below are needed for signing mnping messages going forward
|
//The values below are needed for signing mnping messages going forward
|
||||||
this->vin = newVin;
|
this->vin = newVin;
|
||||||
|
@ -13,6 +13,12 @@
|
|||||||
#include "darksend.h"
|
#include "darksend.h"
|
||||||
#include "masternode.h"
|
#include "masternode.h"
|
||||||
|
|
||||||
|
#define ACTIVE_MASTERNODE_INITIAL 0 // initial state
|
||||||
|
#define ACTIVE_MASTERNODE_SYNC_IN_PROCESS 1
|
||||||
|
#define ACTIVE_MASTERNODE_INPUT_TOO_NEW 2
|
||||||
|
#define ACTIVE_MASTERNODE_NOT_CAPABLE 3
|
||||||
|
#define ACTIVE_MASTERNODE_STARTED 4
|
||||||
|
|
||||||
// Responsible for activating the Masternode and pinging the network
|
// Responsible for activating the Masternode and pinging the network
|
||||||
class CActiveMasternode
|
class CActiveMasternode
|
||||||
{
|
{
|
||||||
@ -44,7 +50,7 @@ public:
|
|||||||
|
|
||||||
CActiveMasternode()
|
CActiveMasternode()
|
||||||
{
|
{
|
||||||
status = MASTERNODE_INITIAL;
|
status = ACTIVE_MASTERNODE_INITIAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Manage status of main Masternode
|
/// Manage status of main Masternode
|
||||||
|
@ -17,13 +17,13 @@ CMasternodeSync::CMasternodeSync()
|
|||||||
lastMasternodeList = 0;
|
lastMasternodeList = 0;
|
||||||
lastMasternodeWinner = 0;
|
lastMasternodeWinner = 0;
|
||||||
lastBudgetItem = 0;
|
lastBudgetItem = 0;
|
||||||
RequestedMasternodeAssets = MASTERNODE_INITIAL;
|
RequestedMasternodeAssets = MASTERNODE_SYNC_INITIAL;
|
||||||
RequestedMasternodeAttempt = 0;
|
RequestedMasternodeAttempt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CMasternodeSync::IsSynced()
|
bool CMasternodeSync::IsSynced()
|
||||||
{
|
{
|
||||||
return (RequestedMasternodeAssets == MASTERNODE_LIST_SYNCED);
|
return (RequestedMasternodeAssets == MASTERNODE_SYNC_FINISHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMasternodeSync::AddedMasternodeList()
|
void CMasternodeSync::AddedMasternodeList()
|
||||||
@ -45,10 +45,10 @@ void CMasternodeSync::GetNextAsset()
|
|||||||
{
|
{
|
||||||
switch(RequestedMasternodeAssets)
|
switch(RequestedMasternodeAssets)
|
||||||
{
|
{
|
||||||
case(MASTERNODE_INITIAL):
|
case(MASTERNODE_SYNC_INITIAL):
|
||||||
RequestedMasternodeAssets = MASTERNODE_SPORK_SETTINGS;
|
RequestedMasternodeAssets = MASTERNODE_SYNC_SPORKS;
|
||||||
break;
|
break;
|
||||||
case(MASTERNODE_SPORK_SETTINGS):
|
case(MASTERNODE_SYNC_SPORKS):
|
||||||
RequestedMasternodeAssets = MASTERNODE_SYNC_LIST;
|
RequestedMasternodeAssets = MASTERNODE_SYNC_LIST;
|
||||||
break;
|
break;
|
||||||
case(MASTERNODE_SYNC_LIST):
|
case(MASTERNODE_SYNC_LIST):
|
||||||
@ -58,7 +58,7 @@ void CMasternodeSync::GetNextAsset()
|
|||||||
RequestedMasternodeAssets = MASTERNODE_SYNC_BUDGET;
|
RequestedMasternodeAssets = MASTERNODE_SYNC_BUDGET;
|
||||||
break;
|
break;
|
||||||
case(MASTERNODE_SYNC_BUDGET):
|
case(MASTERNODE_SYNC_BUDGET):
|
||||||
RequestedMasternodeAssets = MASTERNODE_LIST_SYNCED;
|
RequestedMasternodeAssets = MASTERNODE_SYNC_FINISHED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
RequestedMasternodeAttempt = 0;
|
RequestedMasternodeAttempt = 0;
|
||||||
@ -75,7 +75,7 @@ void CMasternodeSync::Process()
|
|||||||
if(fDebug) LogPrintf("CMasternodeSync::Process() - RequestedMasternodeAssets %d c %d\n", RequestedMasternodeAssets, c);
|
if(fDebug) LogPrintf("CMasternodeSync::Process() - RequestedMasternodeAssets %d c %d\n", RequestedMasternodeAssets, c);
|
||||||
|
|
||||||
//request full mn list only if Masternodes.dat was updated quite a long time ago
|
//request full mn list only if Masternodes.dat was updated quite a long time ago
|
||||||
if(RequestedMasternodeAssets == MASTERNODE_INITIAL) GetNextAsset();
|
if(RequestedMasternodeAssets == MASTERNODE_SYNC_INITIAL) GetNextAsset();
|
||||||
|
|
||||||
CBlockIndex* pindexPrev = chainActive.Tip();
|
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||||
if(pindexPrev == NULL) return;
|
if(pindexPrev == NULL) return;
|
||||||
@ -86,7 +86,7 @@ void CMasternodeSync::Process()
|
|||||||
if (pnode->nVersion >= MIN_POOL_PEER_PROTO_VERSION)
|
if (pnode->nVersion >= MIN_POOL_PEER_PROTO_VERSION)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(RequestedMasternodeAssets == MASTERNODE_SPORK_SETTINGS){
|
if(RequestedMasternodeAssets == MASTERNODE_SYNC_SPORKS){
|
||||||
if(pnode->HasFulfilledRequest("getspork")) continue;
|
if(pnode->HasFulfilledRequest("getspork")) continue;
|
||||||
pnode->FulfilledRequest("getspork");
|
pnode->FulfilledRequest("getspork");
|
||||||
|
|
||||||
|
@ -5,12 +5,12 @@
|
|||||||
#ifndef MASTERNODE_SYNC_H
|
#ifndef MASTERNODE_SYNC_H
|
||||||
#define MASTERNODE_SYNC_H
|
#define MASTERNODE_SYNC_H
|
||||||
|
|
||||||
#define MASTERNODE_INITIAL 0
|
#define MASTERNODE_SYNC_INITIAL 0
|
||||||
#define MASTERNODE_SPORK_SETTINGS 1
|
#define MASTERNODE_SYNC_SPORKS 1
|
||||||
#define MASTERNODE_SYNC_LIST 2
|
#define MASTERNODE_SYNC_LIST 2
|
||||||
#define MASTERNODE_SYNC_MNW 3
|
#define MASTERNODE_SYNC_MNW 3
|
||||||
#define MASTERNODE_SYNC_BUDGET 4
|
#define MASTERNODE_SYNC_BUDGET 4
|
||||||
#define MASTERNODE_LIST_SYNCED 999
|
#define MASTERNODE_SYNC_FINISHED 999
|
||||||
|
|
||||||
#define MASTERNODE_SYNC_TIMEOUT 5
|
#define MASTERNODE_SYNC_TIMEOUT 5
|
||||||
|
|
||||||
|
@ -13,12 +13,6 @@
|
|||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "timedata.h"
|
#include "timedata.h"
|
||||||
|
|
||||||
#define MASTERNODE_INITIAL 0 // initial state
|
|
||||||
#define MASTERNODE_SYNC_IN_PROCESS 1
|
|
||||||
#define MASTERNODE_INPUT_TOO_NEW 2
|
|
||||||
#define MASTERNODE_NOT_CAPABLE 3
|
|
||||||
#define MASTERNODE_STARTED 4
|
|
||||||
|
|
||||||
#define MASTERNODE_MIN_CONFIRMATIONS 15
|
#define MASTERNODE_MIN_CONFIRMATIONS 15
|
||||||
#define MASTERNODE_MIN_MNP_SECONDS (30*60)
|
#define MASTERNODE_MIN_MNP_SECONDS (30*60)
|
||||||
#define MASTERNODE_MIN_MNB_SECONDS (5*60)
|
#define MASTERNODE_MIN_MNB_SECONDS (5*60)
|
||||||
|
@ -199,8 +199,8 @@ Value masternode(const Array& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(activeMasternode.status != MASTERNODE_STARTED){
|
if(activeMasternode.status != ACTIVE_MASTERNODE_STARTED){
|
||||||
activeMasternode.status = MASTERNODE_INITIAL; // TODO: consider better way
|
activeMasternode.status = ACTIVE_MASTERNODE_INITIAL; // TODO: consider better way
|
||||||
activeMasternode.ManageStatus();
|
activeMasternode.ManageStatus();
|
||||||
pwalletMain->Lock();
|
pwalletMain->Lock();
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ Value masternode(const Array& params, bool fHelp)
|
|||||||
|
|
||||||
if (strCommand == "debug")
|
if (strCommand == "debug")
|
||||||
{
|
{
|
||||||
if(activeMasternode.status != MASTERNODE_INITIAL) return activeMasternode.GetStatus();
|
if(activeMasternode.status != ACTIVE_MASTERNODE_INITIAL) return activeMasternode.GetStatus();
|
||||||
|
|
||||||
CTxIn vin = CTxIn();
|
CTxIn vin = CTxIn();
|
||||||
CPubKey pubkey = CScript();
|
CPubKey pubkey = CScript();
|
||||||
|
Loading…
Reference in New Issue
Block a user