diff --git a/src/darksend.cpp b/src/darksend.cpp index f15b5b11bb..cd99ed167f 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -1274,7 +1274,7 @@ bool CMasternodePayments::GetWinningMasternode(int nBlockHeight, CTxIn& vinOut) bool CMasternodePayments::AddWinningMasternode(CMasternodePaymentWinner& winnerIn) { uint256 blockHash = 0; - if(!darkSendPool.GetBlockHash(blockHash, winnerIn.nBlockHeight-10)) { + if(!darkSendPool.GetBlockHash(blockHash, winnerIn.nBlockHeight-100)) { return false; } @@ -1333,11 +1333,10 @@ int CMasternodePayments::LastPayment(CTxIn& vin) bool CMasternodePayments::ProcessBlock(int nBlockHeight) { if(strMasterPrivKey.empty()) return false; - CMasternodePaymentWinner winner; uint256 blockHash = 0; - if(!darkSendPool.GetBlockHash(blockHash, nBlockHeight-10)) return false; + if(!darkSendPool.GetBlockHash(blockHash, nBlockHeight-100)) return false; BOOST_FOREACH(CMasterNode& mn, darkSendMasterNodes) { if(LastPayment(mn.vin) < darkSendMasterNodes.size()) continue; @@ -1350,12 +1349,15 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight) } } + if(winner.nBlockHeight == 0) return false; //no masternodes available + if(Sign(winner)){ if(AddWinningMasternode(winner)){ Relay(winner); return true; } } + return false; } @@ -1382,7 +1384,13 @@ bool CMasternodePayments::SetPrivKey(std::string strPrivKey) strMasterPrivKey = strPrivKey; Sign(winner); - return CheckSignature(winner); + + if(CheckSignature(winner)){ + LogPrintf("Successfully initialized as masternode payments master\n"); + return true; + } else { + return false; + } } diff --git a/src/main.cpp b/src/main.cpp index 48142fb256..a49b99af82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4201,7 +4201,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if(pindexBest == NULL) return false; - if(winner.nBlockHeight > pindexBest->nHeight - 10 || winner.nBlockHeight < pindexBest->nHeight+20){ + if(winner.nBlockHeight < pindexBest->nHeight - 10 || winner.nBlockHeight > pindexBest->nHeight+20){ LogPrintf("mnw - winner out of range %s Height %d bestHeight %d\n", winner.vin.ToString().c_str(), winner.nBlockHeight, pindexBest->nHeight); return false; } @@ -5401,7 +5401,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) //spork if(!masternodePayments.GetBlockPayee(pindexPrev->nHeight+1, pblock->payee)){ //no masternode detected - winningNode = darkSendPool.GetCurrentMasterNode(1); + int winningNode = darkSendPool.GetCurrentMasterNode(1); if(winningNode >= 0){ pblock->payee.SetDestination(darkSendMasterNodes[winningNode].pubkey.GetID()); } else {