From 7240f96e29e9bd3f169c961a240d7c9f576c3f24 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Tue, 24 May 2016 14:16:42 -0700 Subject: [PATCH] - removed hybrid mode (masternode winners reference node). This feature was added to 12.0 incase we had network troubles and required a "safe-mode" to run in. We've experiences no issues like so it should be safe to remove - fixed masternode winners calculation and listing --- src/darksend.cpp | 2 +- src/darksend.h | 2 +- src/main.cpp | 4 +- src/masternode-payments.cpp | 88 ++++++++++++------------------------- src/masternode-payments.h | 6 +-- 5 files changed, 33 insertions(+), 69 deletions(-) diff --git a/src/darksend.cpp b/src/darksend.cpp index 4fb9191e5..39ce72665 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -45,7 +45,7 @@ CActiveMasternode activeMasternode; udjinm6 - udjinm6@dash.org */ -void CDarksendPool::ProcessMessageDarksend(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) +void CDarksendPool::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) { if(fLiteMode) return; //disable all Darksend/Masternode related functionality if(!masternodeSync.IsBlockchainSynced()) return; diff --git a/src/darksend.h b/src/darksend.h index d448d6c69..a38f6980e 100644 --- a/src/darksend.h +++ b/src/darksend.h @@ -360,7 +360,7 @@ public: * dssub | Darksend Subscribe To * \param vRecv */ - void ProcessMessageDarksend(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); + void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); void InitCollateralAddress(){ SetCollateralAddress(Params().DarksendPoolDummyAddress()); diff --git a/src/main.cpp b/src/main.cpp index 2ee7e7f89..57310dd02 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5604,9 +5604,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (found) { //probably one the extensions - darkSendPool.ProcessMessageDarksend(pfrom, strCommand, vRecv); + darkSendPool.ProcessMessage(pfrom, strCommand, vRecv); mnodeman.ProcessMessage(pfrom, strCommand, vRecv); - mnpayments.ProcessMessageMasternodePayments(pfrom, strCommand, vRecv); + mnpayments.ProcessMessage(pfrom, strCommand, vRecv); ProcessMessageInstantX(pfrom, strCommand, vRecv); ProcessSpork(pfrom, strCommand, vRecv); masternodeSync.ProcessMessage(pfrom, strCommand, vRecv); diff --git a/src/masternode-payments.cpp b/src/masternode-payments.cpp index 2f33579ed..db6971a0b 100644 --- a/src/masternode-payments.cpp +++ b/src/masternode-payments.cpp @@ -288,12 +288,15 @@ void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees) std::string GetRequiredPaymentsString(int nBlockHeight) { - // 12.1 + // 12.1 -- added triggered payments + // if(IsSporkActive(SPORK_13_ENABLE_SUPERBLOCKS) && budget.IsBudgetPaymentBlock(nBlockHeight)){ // return budget.GetRequiredPaymentsString(nBlockHeight); // } else { // return mnpayments.GetRequiredPaymentsString(nBlockHeight); // } + + return mnpayments.GetRequiredPaymentsString(nBlockHeight); } void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees) @@ -343,7 +346,7 @@ int CMasternodePayments::GetMinMasternodePaymentsProto() { : MIN_MASTERNODE_PAYMENT_PROTO_VERSION_1; } -void CMasternodePayments::ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) +void CMasternodePayments::ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv) { if(!masternodeSync.IsBlockchainSynced()) return; @@ -500,9 +503,7 @@ bool CMasternodePayments::AddWinningMasternode(CMasternodePaymentWinner& winnerI } } - int n = 1; - if(IsReferenceNode(winnerIn.vinMasternode)) n = 100; - mapMasternodeBlocks[winnerIn.nBlockHeight].AddPayee(winnerIn.payee, n); + mapMasternodeBlocks[winnerIn.nBlockHeight].AddPayee(winnerIn.payee, 1); return true; } @@ -622,20 +623,8 @@ void CMasternodePayments::CheckAndRemove() } } -bool IsReferenceNode(CTxIn& vin) -{ - //reference node - hybrid mode - if(vin.prevout.ToStringShort() == "099c01bea63abd1692f60806bb646fa1d288e2d049281225f17e499024084e28-0") return true; // mainnet - if(vin.prevout.ToStringShort() == "fbc16ae5229d6d99181802fd76a4feee5e7640164dcebc7f8feb04a7bea026f8-0") return true; // testnet - if(vin.prevout.ToStringShort() == "e466f5d8beb4c2d22a314310dc58e0ea89505c95409754d0d68fb874952608cc-1") return true; // regtest - - return false; -} - bool CMasternodePaymentWinner::IsValid(CNode* pnode, std::string& strError) { - if(IsReferenceNode(vinMasternode)) return true; - CMasternode* pmn = mnodeman.Find(vinMasternode); if(!pmn) @@ -675,57 +664,35 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) { if(!fMasterNode) return false; - //reference node - hybrid mode - - if(!IsReferenceNode(activeMasternode.vin)){ - int n = mnodeman.GetMasternodeRank(activeMasternode.vin, nBlockHeight-100, MIN_MNW_PEER_PROTO_VERSION); - - if(n == -1) - { - LogPrint("mnpayments", "CMasternodePayments::ProcessBlock - Unknown Masternode\n"); - return false; - } - - if(n > MNPAYMENTS_SIGNATURES_TOTAL) - { - LogPrint("mnpayments", "CMasternodePayments::ProcessBlock - Masternode not in the top %d (%d)\n", MNPAYMENTS_SIGNATURES_TOTAL, n); - return false; - } - } - - if(nBlockHeight <= nLastBlockHeight) return false; - CMasternodePaymentWinner newWinner(activeMasternode.vin); - // 12.1 - // if(budget.IsBudgetPaymentBlock(nBlockHeight)){ - // //is budget payment block -- handled by the budgeting software - // } else { - // LogPrintf("CMasternodePayments::ProcessBlock() Start nHeight %d - vin %s. \n", nBlockHeight, activeMasternode.vin.ToString()); + // LOCATE THE NEXT MASTERNODE WHICH SHOULD BE PAID - // // pay to the oldest MN that still had no payment but its input is old enough and it was active long enough - // int nCount = 0; - // CMasternode *pmn = mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, nCount); + { + LogPrintf("CMasternodePayments::ProcessBlock() Start nHeight %d - vin %s. \n", nBlockHeight, activeMasternode.vin.ToString()); + + // pay to the oldest MN that still had no payment but its input is old enough and it was active long enough + int nCount = 0; + CMasternode *pmn = mnodeman.GetNextMasternodeInQueueForPayment(nBlockHeight, true, nCount); - // if(pmn != NULL) - // { - // LogPrintf("CMasternodePayments::ProcessBlock() Found by FindOldestNotInVec \n"); + if(pmn != NULL) + { + LogPrintf("CMasternodePayments::ProcessBlock() Found by FindOldestNotInVec \n"); - // newWinner.nBlockHeight = nBlockHeight; + newWinner.nBlockHeight = nBlockHeight; - // CScript payee = GetScriptForDestination(pmn->pubkey.GetID()); - // newWinner.AddPayee(payee); + CScript payee = GetScriptForDestination(pmn->pubkey.GetID()); + newWinner.AddPayee(payee); - // CTxDestination address1; - // ExtractDestination(payee, address1); - // CBitcoinAddress address2(address1); + CTxDestination address1; + ExtractDestination(payee, address1); + CBitcoinAddress address2(address1); - // LogPrintf("CMasternodePayments::ProcessBlock() Winner payee %s nHeight %d. \n", address2.ToString(), newWinner.nBlockHeight); - // } else { - // LogPrintf("CMasternodePayments::ProcessBlock() Failed to find masternode to pay\n"); - // } - - // } + LogPrintf("CMasternodePayments::ProcessBlock() Winner payee %s nHeight %d. \n", address2.ToString(), newWinner.nBlockHeight); + } else { + LogPrintf("CMasternodePayments::ProcessBlock() Failed to find masternode to pay\n"); + } + } std::string errorMessage; CPubKey pubKeyMasternode; @@ -745,7 +712,6 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) if(AddWinningMasternode(newWinner)) { newWinner.Relay(); - nLastBlockHeight = nBlockHeight; return true; } } diff --git a/src/masternode-payments.h b/src/masternode-payments.h index b0a89009a..d40cbfa9a 100644 --- a/src/masternode-payments.h +++ b/src/masternode-payments.h @@ -29,7 +29,7 @@ extern CMasternodePayments mnpayments; #define MNPAYMENTS_SIGNATURES_REQUIRED 6 #define MNPAYMENTS_SIGNATURES_TOTAL 10 -void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); +void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); bool IsReferenceNode(CTxIn& vin); bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight); std::string GetRequiredPaymentsString(int nBlockHeight); @@ -225,7 +225,6 @@ class CMasternodePayments { private: int nSyncedFromPeer; - int nLastBlockHeight; // Keep track of current block index const CBlockIndex *pCurrentBlockIndex; @@ -236,7 +235,6 @@ public: CMasternodePayments() { nSyncedFromPeer = 0; - nLastBlockHeight = 0; } void Clear() { @@ -271,7 +269,7 @@ public: } int GetMinMasternodePaymentsProto(); - void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); + void ProcessMessage(CNode* pfrom, std::string& strCommand, CDataStream& vRecv); std::string GetRequiredPaymentsString(int nBlockHeight); void FillBlockPayee(CMutableTransaction& txNew, CAmount nFees); std::string ToString() const;