Skip to content

Commit

Permalink
Skip initial masternode list sync if spork 15 is active
Browse files Browse the repository at this point in the history
  • Loading branch information
codablock committed Sep 3, 2018
1 parent d90b139 commit 6764daf
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions src/masternode-sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "spork.h"
#include "ui_interface.h"
#include "util.h"
#include "evo/deterministicmns.h"

class CMasternodeSync;
CMasternodeSync masternodeSync;
Expand Down Expand Up @@ -69,12 +70,20 @@ void CMasternodeSync::SwitchToNextAsset(CConnman& connman)
break;
case(MASTERNODE_SYNC_WAITING):
LogPrintf("CMasternodeSync::SwitchToNextAsset -- Completed %s in %llds\n", GetAssetName(), GetTime() - nTimeAssetSyncStarted);
nRequestedMasternodeAssets = MASTERNODE_SYNC_LIST;
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
nRequestedMasternodeAssets = MASTERNODE_SYNC_GOVERNANCE;
} else {
nRequestedMasternodeAssets = MASTERNODE_SYNC_LIST;
}
LogPrintf("CMasternodeSync::SwitchToNextAsset -- Starting %s\n", GetAssetName());
break;
case(MASTERNODE_SYNC_LIST):
LogPrintf("CMasternodeSync::SwitchToNextAsset -- Completed %s in %llds\n", GetAssetName(), GetTime() - nTimeAssetSyncStarted);
nRequestedMasternodeAssets = MASTERNODE_SYNC_MNW;
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
nRequestedMasternodeAssets = MASTERNODE_SYNC_GOVERNANCE;
} else {
nRequestedMasternodeAssets = MASTERNODE_SYNC_MNW;
}
LogPrintf("CMasternodeSync::SwitchToNextAsset -- Starting %s\n", GetAssetName());
break;
case(MASTERNODE_SYNC_MNW):
Expand Down Expand Up @@ -188,14 +197,18 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::GETSPORKS)); //get current network sporks
SwitchToNextAsset(connman);
} else if (nRequestedMasternodeAssets == MASTERNODE_SYNC_LIST) {
mnodeman.DsegUpdate(pnode, connman);
if (!deterministicMNManager->IsDeterministicMNsSporkActive()) {
mnodeman.DsegUpdate(pnode, connman);
}
SwitchToNextAsset(connman);
} else if (nRequestedMasternodeAssets == MASTERNODE_SYNC_MNW) {
//sync payment votes
if(pnode->nVersion == 70208) {
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::MASTERNODEPAYMENTSYNC, mnpayments.GetStorageLimit())); //sync payment votes
} else {
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::MASTERNODEPAYMENTSYNC)); //sync payment votes
if (!deterministicMNManager->IsDeterministicMNsSporkActive()) {
//sync payment votes
if(pnode->nVersion == 70208) {
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::MASTERNODEPAYMENTSYNC, mnpayments.GetStorageLimit())); //sync payment votes
} else {
connman.PushMessage(pnode, msgMaker.Make(NetMsgType::MASTERNODEPAYMENTSYNC)); //sync payment votes
}
}
SwitchToNextAsset(connman);
} else if (nRequestedMasternodeAssets == MASTERNODE_SYNC_GOVERNANCE) {
Expand Down Expand Up @@ -245,6 +258,12 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
// MNLIST : SYNC MASTERNODE LIST FROM OTHER CONNECTED CLIENTS

if(nRequestedMasternodeAssets == MASTERNODE_SYNC_LIST) {
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
SwitchToNextAsset(connman);
connman.ReleaseNodeVector(vNodesCopy);
return;
}

LogPrint("masternode", "CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d nTimeLastBumped %lld GetTime() %lld diff %lld\n", nTick, nRequestedMasternodeAssets, nTimeLastBumped, GetTime(), GetTime() - nTimeLastBumped);
// check for timeout first
if(GetTime() - nTimeLastBumped > MASTERNODE_SYNC_TIMEOUT_SECONDS) {
Expand Down Expand Up @@ -283,6 +302,12 @@ void CMasternodeSync::ProcessTick(CConnman& connman)
// MNW : SYNC MASTERNODE PAYMENT VOTES FROM OTHER CONNECTED CLIENTS

if(nRequestedMasternodeAssets == MASTERNODE_SYNC_MNW) {
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
SwitchToNextAsset(connman);
connman.ReleaseNodeVector(vNodesCopy);
return;
}

LogPrint("mnpayments", "CMasternodeSync::ProcessTick -- nTick %d nRequestedMasternodeAssets %d nTimeLastBumped %lld GetTime() %lld diff %lld\n", nTick, nRequestedMasternodeAssets, nTimeLastBumped, GetTime(), GetTime() - nTimeLastBumped);
// check for timeout first
// This might take a lot longer than MASTERNODE_SYNC_TIMEOUT_SECONDS due to new blocks,
Expand Down

0 comments on commit 6764daf

Please sign in to comment.