Skip to content

Commit

Permalink
Mnsync next
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquid369 committed Mar 28, 2023
1 parent f3c25d5 commit 0f9206d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ class CMainParams : public CChainParams
// validation by-pass
consensus.nDogeCashBadBlockTime = 1593294062; // Skip nBit validation of Block 259201 per PR #915
consensus.nDogeCashBadBlockBits = 488380309; // Skip nBit validation of Block 259201 per PR #915
consensus.nDogeCashV55MNWindow = 1970000;

// Zerocoin-related params
consensus.ZC_Modulus = "25195908475657893494027183240048398571429282126204032027777137836043662020707595556264018525880784"
Expand All @@ -314,7 +315,7 @@ class CMainParams : public CChainParams
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_POS].nActivationHeight = 201;
consensus.vUpgrades[Consensus::UPGRADE_POS_V2].nActivationHeight = 601339;
consensus.vUpgrades[Consensus::UPGRADE_ZC].nActivationHeight = 1;
consensus.vUpgrades[Consensus::UPGRADE_ZC].nActivationHeight = 5000;
consensus.vUpgrades[Consensus::UPGRADE_ZC_V2].nActivationHeight = 1;
consensus.vUpgrades[Consensus::UPGRADE_BIP65].nActivationHeight = 1;
consensus.vUpgrades[Consensus::UPGRADE_ZC_PUBLIC].nActivationHeight = INT_MAX;
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ struct Params {
// validation by-pass
int64_t nDogeCashBadBlockTime;
unsigned int nDogeCashBadBlockBits;
int nDogeCashV55MNWindow;

CAmount nDevReward;

Expand Down
4 changes: 3 additions & 1 deletion src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include "addrman.h"
#include "masternodeman.h"
#include "netbase.h"
#include "spork.h"
#include "sporkdb.h"
#include "sync.h"
#include "tiertwo/tiertwo_sync_state.h"
#include "wallet/wallet.h"
Expand Down Expand Up @@ -234,7 +236,7 @@ bool CMasternodeBroadcast::Create(const std::string& strService,
CKey keyMasternodeNew;

//need correct blocks to send ping
if (!fOffline && !g_tiertwo_sync_state.IsBlockchainSynced()) {
if ((!fOffline && !g_tiertwo_sync_state.IsBlockchainSynced()) || (chainHeight <= Params().GetConsensus().nDogeCashV55MNWindow && !sporkManager.IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT))) {
strErrorRet = "Sync in progress. Must wait until sync is complete to start Masternode";
LogPrint(BCLog::MASTERNODE,"CMasternodeBroadcast::Create -- %s\n", strErrorRet);
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ int CMasternodeMan::ProcessMNBroadcast(CNode* pfrom, CMasternodeBroadcast& mnb)
// Relay only if we are synchronized and if the mnb address is not local.
// Makes no sense to relay MNBs to the peers from where we are syncing them.
bool isLocal = (mnb.addr.IsRFC1918() || mnb.addr.IsLocal()) && !Params().IsRegTestNet();
if (!isLocal && g_tiertwo_sync_state.IsSynced()) mnb.Relay();
if ((!isLocal && g_tiertwo_sync_state.IsSynced()) || (chainHeight <= Params().GetConsensus().nDogeCashV55MNWindow && !sporkManager.IsSporkActive(SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT))) mnb.Relay();

// Add it as a peer
g_connman->AddNewAddress(CAddress(mnb.addr, NODE_NETWORK), pfrom->addr, 2 * 60 * 60);
Expand Down
8 changes: 6 additions & 2 deletions src/rpc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ UniValue mnsync(const JSONRPCRequest& request)
if (request.params.size() == 1)
strMode = request.params[0].get_str();

if (request.fHelp || request.params.size() != 1 || (strMode != "status" && strMode != "reset")) {
if (request.fHelp || request.params.size() != 1 || (strMode != "status" && strMode != "reset" && strMode != "next")) {
throw std::runtime_error(
"mnsync \"status|reset\"\n"
"mnsync \"status|reset|next\"\n"
"\nReturns the sync status or resets sync.\n"

"\nArguments:\n"
Expand Down Expand Up @@ -223,6 +223,10 @@ UniValue mnsync(const JSONRPCRequest& request)
masternodeSync.Reset();
return "success";
}
if (strMode == "next") {
masternodeSync.SwitchToNextAsset();
return masternodeSync.GetSyncStatus();
}
return "failure";
}

Expand Down

0 comments on commit 0f9206d

Please sign in to comment.