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 "warnings.h"
#include "evo/deterministicmns.h"
/** Masternode manager */
CMasternodeMan mnodeman;
@ -79,6 +81,9 @@ bool CMasternodeMan::Add(CMasternode &mn)
{
LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
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);
@ -94,6 +99,9 @@ void CMasternodeMan::AskForMN(CNode* pnode, const COutPoint& outpoint, CConnman&
CNetMsgMaker msgMaker(pnode->GetSendVersion());
LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
CService addrSquashed = Params().AllowMultiplePorts() ? (CService)pnode->addr : CService(pnode->addr, 0);
auto it1 = mWeAskedForMasternodeListEntry.find(outpoint);
if (it1 != mWeAskedForMasternodeListEntry.end()) {
@ -151,6 +159,10 @@ bool CMasternodeMan::DisallowMixing(const COutPoint &outpoint)
bool CMasternodeMan::PoSeBan(const COutPoint &outpoint)
{
LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return true;
CMasternode* pmn = Find(outpoint);
if (!pmn) {
return false;
@ -164,6 +176,9 @@ void CMasternodeMan::Check()
{
LOCK2(cs_main, cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
for (auto& mnpair : mapMasternodes) {
// NOTE: internally it checks only every MASTERNODE_CHECK_SECONDS seconds
// since the last time, so expect some MNs to skip this
@ -173,6 +188,9 @@ void CMasternodeMan::Check()
void CMasternodeMan::CheckAndRemove(CConnman& connman)
{
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
if(!masternodeSync.IsMasternodeListSynced()) return;
LogPrintf("CMasternodeMan::CheckAndRemove\n");
@ -418,6 +436,9 @@ void CMasternodeMan::DsegUpdate(CNode* pnode, CConnman& connman)
CNetMsgMaker msgMaker(pnode->GetSendVersion());
LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
CService addrSquashed = Params().AllowMultiplePorts() ? (CService)pnode->addr : CService(pnode->addr, 0);
if(Params().NetworkIDString() == CBaseChainParams::MAIN) {
if(!(pnode->addr.IsRFC1918() || pnode->addr.IsLocal())) {
@ -740,6 +761,9 @@ void CMasternodeMan::ProcessMasternodeConnections(CConnman& connman)
std::pair<CService, std::set<uint256> > CMasternodeMan::PopScheduledMnbRequestConnection()
{
LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive()) {
return std::make_pair(CService(), std::set<uint256>());
}
if(listScheduledMnbRequestConnections.empty()) {
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)
{
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
std::pair<CService, std::set<uint256> > p = PopScheduledMnbRequestConnection();
if (!(p.first == CService() || p.second.empty())) {
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)
{
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
if(fLiteMode) return; // disable all Dash specific functionality
if (strCommand == NetMsgType::MNANNOUNCE) { //Masternode Broadcast
@ -1001,6 +1031,9 @@ void CMasternodeMan::PushDsegInvs(CNode* pnode, const CMasternode& mn)
void CMasternodeMan::DoFullVerificationStep(CConnman& connman)
{
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
if(activeMasternodeInfo.outpoint.IsNull()) return;
if(!masternodeSync.IsSynced()) return;
@ -1078,6 +1111,9 @@ void CMasternodeMan::DoFullVerificationStep(CConnman& connman)
void CMasternodeMan::CheckSameAddr()
{
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
if(!masternodeSync.IsSynced() || mapMasternodes.empty()) return;
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)
{
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return false;
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
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);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
std::map<CService, std::pair<int64_t, CMasternodeVerification> >::iterator itPendingMNV = mapPendingMNV.begin();
while (itPendingMNV != mapPendingMNV.end()) {
@ -1181,6 +1223,9 @@ void CMasternodeMan::SendVerifyReply(CNode* pnode, CMasternodeVerification& mnv,
{
AssertLockHeld(cs_main);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
// only masternodes can sign this, why would someone ask regular node?
if(!fMasternodeMode) {
// do not ban, malicious node might be using my IP
@ -1238,6 +1283,9 @@ void CMasternodeMan::ProcessVerifyReply(CNode* pnode, CMasternodeVerification& m
{
AssertLockHeld(cs_main);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
std::string strError;
// 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);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
std::string strError;
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
LOCK(cs_main);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return false;
{
LOCK(cs);
nDos = 0;
@ -1621,6 +1675,8 @@ void CMasternodeMan::UpdateLastPaid(const CBlockIndex* pindex)
void CMasternodeMan::UpdateLastSentinelPingTime()
{
LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
nLastSentinelPingTime = GetTime();
}
@ -1653,6 +1709,8 @@ void CMasternodeMan::RemoveGovernanceObject(uint256 nGovernanceObjectHash)
void CMasternodeMan::CheckMasternode(const CKeyID& keyIDOperator, bool fForce)
{
LOCK2(cs_main, cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
for (auto& mnpair : mapMasternodes) {
if (mnpair.second.keyIDOperator == keyIDOperator) {
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)
{
LOCK(cs);
if (deterministicMNManager->IsDeterministicMNsSporkActive())
return;
CMasternode* pmn = Find(outpoint);
if(!pmn) {
return;

View File

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