- 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
This commit is contained in:
Evan Duffield 2016-05-24 14:16:42 -07:00
parent 26b297f7fd
commit 7240f96e29
5 changed files with 33 additions and 69 deletions

View File

@ -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;

View File

@ -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());

View File

@ -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);

View File

@ -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());
// if(pmn != NULL)
// {
// LogPrintf("CMasternodePayments::ProcessBlock() Found by FindOldestNotInVec \n");
// 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);
// newWinner.nBlockHeight = nBlockHeight;
if(pmn != NULL)
{
LogPrintf("CMasternodePayments::ProcessBlock() Found by FindOldestNotInVec \n");
// CScript payee = GetScriptForDestination(pmn->pubkey.GetID());
// newWinner.AddPayee(payee);
newWinner.nBlockHeight = nBlockHeight;
// CTxDestination address1;
// ExtractDestination(payee, address1);
// CBitcoinAddress address2(address1);
CScript payee = GetScriptForDestination(pmn->pubkey.GetID());
newWinner.AddPayee(payee);
// LogPrintf("CMasternodePayments::ProcessBlock() Winner payee %s nHeight %d. \n", address2.ToString(), newWinner.nBlockHeight);
// } else {
// LogPrintf("CMasternodePayments::ProcessBlock() Failed to find masternode to pay\n");
// }
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");
}
}
std::string errorMessage;
CPubKey pubKeyMasternode;
@ -745,7 +712,6 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
if(AddWinningMasternode(newWinner))
{
newWinner.Relay();
nLastBlockHeight = nBlockHeight;
return true;
}
}

View File

@ -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;