Stop executing legacy MN list code when spork 15 is activated

This commit is contained in:
Alexander Block 2018-02-16 14:09:42 +01:00
parent 6764dafece
commit 27e8b48a60
2 changed files with 70 additions and 6 deletions

View File

@ -22,6 +22,8 @@
#include "util.h" #include "util.h"
#include "warnings.h" #include "warnings.h"
#include "evo/deterministicmns.h"
/** Masternode manager */ /** Masternode manager */
CMasternodeMan mnodeman; CMasternodeMan mnodeman;
@ -79,6 +81,9 @@ bool CMasternodeMan::Add(CMasternode &mn)
{ {
LOCK(cs); LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return false;
if (Has(mn.outpoint)) return false; if (Has(mn.outpoint)) return false;
LogPrint("masternode", "CMasternodeMan::Add -- Adding new Masternode: addr=%s, %i now\n", mn.addr.ToString(), size() + 1); LogPrint("masternode", "CMasternodeMan::Add -- Adding new Masternode: addr=%s, %i now\n", mn.addr.ToString(), size() + 1);
@ -94,6 +99,9 @@ void CMasternodeMan::AskForMN(CNode* pnode, const COutPoint& outpoint, CConnman&
CNetMsgMaker msgMaker(pnode->GetSendVersion()); CNetMsgMaker msgMaker(pnode->GetSendVersion());
LOCK(cs); LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
CService addrSquashed = Params().AllowMultiplePorts() ? (CService)pnode->addr : CService(pnode->addr, 0); CService addrSquashed = Params().AllowMultiplePorts() ? (CService)pnode->addr : CService(pnode->addr, 0);
auto it1 = mWeAskedForMasternodeListEntry.find(outpoint); auto it1 = mWeAskedForMasternodeListEntry.find(outpoint);
if (it1 != mWeAskedForMasternodeListEntry.end()) { if (it1 != mWeAskedForMasternodeListEntry.end()) {
@ -151,6 +159,10 @@ bool CMasternodeMan::DisallowMixing(const COutPoint &outpoint)
bool CMasternodeMan::PoSeBan(const COutPoint &outpoint) bool CMasternodeMan::PoSeBan(const COutPoint &outpoint)
{ {
LOCK(cs); LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return true;
CMasternode* pmn = Find(outpoint); CMasternode* pmn = Find(outpoint);
if (!pmn) { if (!pmn) {
return false; return false;
@ -164,6 +176,9 @@ void CMasternodeMan::Check()
{ {
LOCK2(cs_main, cs); LOCK2(cs_main, cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
for (auto& mnpair : mapMasternodes) { for (auto& mnpair : mapMasternodes) {
// NOTE: internally it checks only every MASTERNODE_CHECK_SECONDS seconds // NOTE: internally it checks only every MASTERNODE_CHECK_SECONDS seconds
// since the last time, so expect some MNs to skip this // since the last time, so expect some MNs to skip this
@ -173,6 +188,9 @@ void CMasternodeMan::Check()
void CMasternodeMan::CheckAndRemove(CConnman& connman) void CMasternodeMan::CheckAndRemove(CConnman& connman)
{ {
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
if(!masternodeSync.IsMasternodeListSynced()) return; if(!masternodeSync.IsMasternodeListSynced()) return;
LogPrintf("CMasternodeMan::CheckAndRemove\n"); LogPrintf("CMasternodeMan::CheckAndRemove\n");
@ -418,6 +436,9 @@ void CMasternodeMan::DsegUpdate(CNode* pnode, CConnman& connman)
CNetMsgMaker msgMaker(pnode->GetSendVersion()); CNetMsgMaker msgMaker(pnode->GetSendVersion());
LOCK(cs); LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
CService addrSquashed = Params().AllowMultiplePorts() ? (CService)pnode->addr : CService(pnode->addr, 0); CService addrSquashed = Params().AllowMultiplePorts() ? (CService)pnode->addr : CService(pnode->addr, 0);
if(Params().NetworkIDString() == CBaseChainParams::MAIN) { if(Params().NetworkIDString() == CBaseChainParams::MAIN) {
if(!(pnode->addr.IsRFC1918() || pnode->addr.IsLocal())) { if(!(pnode->addr.IsRFC1918() || pnode->addr.IsLocal())) {
@ -740,6 +761,9 @@ void CMasternodeMan::ProcessMasternodeConnections(CConnman& connman)
std::pair<CService, std::set<uint256> > CMasternodeMan::PopScheduledMnbRequestConnection() std::pair<CService, std::set<uint256> > CMasternodeMan::PopScheduledMnbRequestConnection()
{ {
LOCK(cs); LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
return std::make_pair(CService(), std::set<uint256>());
}
if(listScheduledMnbRequestConnections.empty()) { if(listScheduledMnbRequestConnections.empty()) {
return std::make_pair(CService(), std::set<uint256>()); return std::make_pair(CService(), std::set<uint256>());
} }
@ -766,6 +790,9 @@ std::pair<CService, std::set<uint256> > CMasternodeMan::PopScheduledMnbRequestCo
void CMasternodeMan::ProcessPendingMnbRequests(CConnman& connman) void CMasternodeMan::ProcessPendingMnbRequests(CConnman& connman)
{ {
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
std::pair<CService, std::set<uint256> > p = PopScheduledMnbRequestConnection(); std::pair<CService, std::set<uint256> > p = PopScheduledMnbRequestConnection();
if (!(p.first == CService() || p.second.empty())) { if (!(p.first == CService() || p.second.empty())) {
if (connman.IsMasternodeOrDisconnectRequested(p.first)) return; if (connman.IsMasternodeOrDisconnectRequested(p.first)) return;
@ -805,6 +832,9 @@ void CMasternodeMan::ProcessPendingMnbRequests(CConnman& connman)
void CMasternodeMan::ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman) void CMasternodeMan::ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman)
{ {
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
if(fLiteMode) return; // disable all Dash specific functionality if(fLiteMode) return; // disable all Dash specific functionality
if (strCommand == NetMsgType::MNANNOUNCE) { //Masternode Broadcast if (strCommand == NetMsgType::MNANNOUNCE) { //Masternode Broadcast
@ -1001,6 +1031,9 @@ void CMasternodeMan::PushDsegInvs(CNode* pnode, const CMasternode& mn)
void CMasternodeMan::DoFullVerificationStep(CConnman& connman) void CMasternodeMan::DoFullVerificationStep(CConnman& connman)
{ {
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
if(activeMasternodeInfo.outpoint.IsNull()) return; if(activeMasternodeInfo.outpoint.IsNull()) return;
if(!masternodeSync.IsSynced()) return; if(!masternodeSync.IsSynced()) return;
@ -1078,6 +1111,9 @@ void CMasternodeMan::DoFullVerificationStep(CConnman& connman)
void CMasternodeMan::CheckSameAddr() void CMasternodeMan::CheckSameAddr()
{ {
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
if(!masternodeSync.IsSynced() || mapMasternodes.empty()) return; if(!masternodeSync.IsSynced() || mapMasternodes.empty()) return;
std::vector<CMasternode*> vBan; std::vector<CMasternode*> vBan;
@ -1131,6 +1167,9 @@ void CMasternodeMan::CheckSameAddr()
bool CMasternodeMan::SendVerifyRequest(const CAddress& addr, const std::vector<const CMasternode*>& vSortedByAddr, CConnman& connman) bool CMasternodeMan::SendVerifyRequest(const CAddress& addr, const std::vector<const CMasternode*>& vSortedByAddr, CConnman& connman)
{ {
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return false;
if(netfulfilledman.HasFulfilledRequest(addr, strprintf("%s", NetMsgType::MNVERIFY)+"-request")) { if(netfulfilledman.HasFulfilledRequest(addr, strprintf("%s", NetMsgType::MNVERIFY)+"-request")) {
// we already asked for verification, not a good idea to do this too often, skip it // we already asked for verification, not a good idea to do this too often, skip it
LogPrint("masternode", "CMasternodeMan::SendVerifyRequest -- too many requests, skipping... addr=%s\n", addr.ToString()); LogPrint("masternode", "CMasternodeMan::SendVerifyRequest -- too many requests, skipping... addr=%s\n", addr.ToString());
@ -1152,6 +1191,9 @@ void CMasternodeMan::ProcessPendingMnvRequests(CConnman& connman)
{ {
LOCK(cs_mapPendingMNV); LOCK(cs_mapPendingMNV);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
std::map<CService, std::pair<int64_t, CMasternodeVerification> >::iterator itPendingMNV = mapPendingMNV.begin(); std::map<CService, std::pair<int64_t, CMasternodeVerification> >::iterator itPendingMNV = mapPendingMNV.begin();
while (itPendingMNV != mapPendingMNV.end()) { while (itPendingMNV != mapPendingMNV.end()) {
@ -1181,6 +1223,9 @@ void CMasternodeMan::SendVerifyReply(CNode* pnode, CMasternodeVerification& mnv,
{ {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
// only masternodes can sign this, why would someone ask regular node? // only masternodes can sign this, why would someone ask regular node?
if(!fMasternodeMode) { if(!fMasternodeMode) {
// do not ban, malicious node might be using my IP // do not ban, malicious node might be using my IP
@ -1238,6 +1283,9 @@ void CMasternodeMan::ProcessVerifyReply(CNode* pnode, CMasternodeVerification& m
{ {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
std::string strError; std::string strError;
// did we even ask for it? if that's the case we should have matching fulfilled request // did we even ask for it? if that's the case we should have matching fulfilled request
@ -1374,6 +1422,9 @@ void CMasternodeMan::ProcessVerifyBroadcast(CNode* pnode, const CMasternodeVerif
{ {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
std::string strError; std::string strError;
if(mapSeenMasternodeVerification.find(mnv.GetHash()) != mapSeenMasternodeVerification.end()) { if(mapSeenMasternodeVerification.find(mnv.GetHash()) != mapSeenMasternodeVerification.end()) {
@ -1509,6 +1560,9 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CNode* pfrom, CMasternodeBr
// Need to lock cs_main here to ensure consistent locking order because the SimpleCheck call below locks cs_main // Need to lock cs_main here to ensure consistent locking order because the SimpleCheck call below locks cs_main
LOCK(cs_main); LOCK(cs_main);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return false;
{ {
LOCK(cs); LOCK(cs);
nDos = 0; nDos = 0;
@ -1621,6 +1675,8 @@ void CMasternodeMan::UpdateLastPaid(const CBlockIndex* pindex)
void CMasternodeMan::UpdateLastSentinelPingTime() void CMasternodeMan::UpdateLastSentinelPingTime()
{ {
LOCK(cs); LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
nLastSentinelPingTime = GetTime(); nLastSentinelPingTime = GetTime();
} }
@ -1653,6 +1709,8 @@ void CMasternodeMan::RemoveGovernanceObject(uint256 nGovernanceObjectHash)
void CMasternodeMan::CheckMasternode(const CKeyID& keyIDOperator, bool fForce) void CMasternodeMan::CheckMasternode(const CKeyID& keyIDOperator, bool fForce)
{ {
LOCK2(cs_main, cs); LOCK2(cs_main, cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
for (auto& mnpair : mapMasternodes) { for (auto& mnpair : mapMasternodes) {
if (mnpair.second.keyIDOperator == keyIDOperator) { if (mnpair.second.keyIDOperator == keyIDOperator) {
mnpair.second.Check(fForce); mnpair.second.Check(fForce);
@ -1671,6 +1729,8 @@ bool CMasternodeMan::IsMasternodePingedWithin(const COutPoint& outpoint, int nSe
void CMasternodeMan::SetMasternodeLastPing(const COutPoint& outpoint, const CMasternodePing& mnp) void CMasternodeMan::SetMasternodeLastPing(const COutPoint& outpoint, const CMasternodePing& mnp)
{ {
LOCK(cs); LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
CMasternode* pmn = Find(outpoint); CMasternode* pmn = Find(outpoint);
if(!pmn) { if(!pmn) {
return; return;

View File

@ -1201,18 +1201,22 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
} }
if (!push && inv.type == MSG_MASTERNODE_ANNOUNCE) { if (!push && inv.type == MSG_MASTERNODE_ANNOUNCE) {
if(mnodeman.mapSeenMasternodeBroadcast.count(inv.hash)){ if (!deterministicMNManager->IsDeterministicMNsSporkActive()) {
if (mnodeman.mapSeenMasternodeBroadcast.count(inv.hash)) {
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::MNANNOUNCE, mnodeman.mapSeenMasternodeBroadcast[inv.hash].second)); connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::MNANNOUNCE, mnodeman.mapSeenMasternodeBroadcast[inv.hash].second));
push = true; push = true;
} }
} }
}
if (!push && inv.type == MSG_MASTERNODE_PING) { if (!push && inv.type == MSG_MASTERNODE_PING) {
if(mnodeman.mapSeenMasternodePing.count(inv.hash)) { if (!deterministicMNManager->IsDeterministicMNsSporkActive()) {
if (mnodeman.mapSeenMasternodePing.count(inv.hash)) {
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::MNPING, mnodeman.mapSeenMasternodePing[inv.hash])); connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::MNPING, mnodeman.mapSeenMasternodePing[inv.hash]));
push = true; push = true;
} }
} }
}
if (!push && inv.type == MSG_DSTX) { if (!push && inv.type == MSG_DSTX) {
CDarksendBroadcastTx dstx = CPrivateSend::GetDSTX(inv.hash); CDarksendBroadcastTx dstx = CPrivateSend::GetDSTX(inv.hash);