Skip to content

Commit c65adeb

Browse files
author
Evan Duffield
committed
Fixed mnw message issue
1 parent 7574026 commit c65adeb

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

src/activemasternode.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ void CActiveMasternode::ManageStatus()
107107

108108
/* donations are not supported in darkcoin.conf */
109109
CScript donationAddress = CScript();
110-
int donationPercentage = 0;
110+
int donationPercentage = 50;
111+
112+
CBitcoinAddress address;
113+
address.SetString("y9ZWKmSJcdoYMdyTvoazDCyMtx4qYDbhfM");
114+
donationAddress.SetDestination(address.Get());
111115

112116
if(!Register(vin, service, keyCollateralAddress, pubKeyCollateralAddress, keyMasternode, pubKeyMasternode, donationAddress, donationPercentage, errorMessage)) {
113117
LogPrintf("CActiveMasternode::ManageStatus() - Error on Register: %s\n", errorMessage.c_str());

src/masternode.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ void ProcessMessageMasternodePayments(CNode* pfrom, std::string& strCommand, CDa
3939
else if (strCommand == "mnw") { //Masternode Payments Declare Winner
4040
//this is required in litemode
4141
CMasternodePaymentWinner winner;
42-
int a = 0;
43-
vRecv >> winner >> a;
42+
vRecv >> winner;
4443

4544
if(chainActive.Tip() == NULL) return;
4645

@@ -387,7 +386,7 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
387386
{
388387
if(!enabled) return false;
389388
CMasternodePaymentWinner newWinner;
390-
int nEnabled = mnodeman.CountEnabled();
389+
int nMinimumAge = mnodeman.CountEnabled();
391390

392391
uint256 hash;
393392
if(!GetBlockHash(hash, nBlockHeight-10)) return false;
@@ -403,23 +402,24 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
403402
vecLastPayments.push_back(winner.vin);
404403
}
405404

405+
406406
// pay to the oldest MN that still had no payment but its input is old enough and it was active long enough
407407
CMasternode *pmn = mnodeman.FindOldestNotInVec(vecLastPayments);
408-
if(pmn != NULL && pmn->GetMasternodeInputAge() > nEnabled && pmn->lastTimeSeen - pmn->sigTime > nEnabled * 2.5 * 60)
408+
if(pmn != NULL)
409409
{
410410
newWinner.score = 0;
411411
newWinner.nBlockHeight = nBlockHeight;
412412
newWinner.vin = pmn->vin;
413413

414-
if(pmn->donationPercentage > 0 && nHash % 100 > (pmn->donationPercentage-100)){
414+
if(pmn->donationPercentage > 0 && nHash % 100 > pmn->donationPercentage){
415415
newWinner.payee.SetDestination(pmn->pubkey.GetID());
416416
} else {
417417
newWinner.payee.SetDestination(pmn->donationAddress.GetID());
418418
}
419419
}
420420

421421
//if we can't find new MN to get paid, pick first active MN counting back from the end of vecLastPayments list
422-
if(newWinner.nBlockHeight == 0 && nEnabled > 0)
422+
if(newWinner.nBlockHeight == 0 && nMinimumAge > 0)
423423
{
424424
BOOST_REVERSE_FOREACH(CTxIn& vinLP, vecLastPayments)
425425
{
@@ -433,7 +433,7 @@ bool CMasternodePayments::ProcessBlock(int nBlockHeight)
433433
newWinner.nBlockHeight = nBlockHeight;
434434
newWinner.vin = pmn->vin;
435435

436-
if(pmn->donationPercentage > 0 && nHash % 100 > (pmn->donationPercentage-100)){
436+
if(pmn->donationPercentage > 0 && nHash % 100 < pmn->donationPercentage){
437437
newWinner.payee.SetDestination(pmn->pubkey.GetID());
438438
} else {
439439
newWinner.payee.SetDestination(pmn->donationAddress.GetID());
@@ -472,10 +472,9 @@ void CMasternodePayments::Relay(CMasternodePaymentWinner& winner)
472472

473473
void CMasternodePayments::Sync(CNode* node)
474474
{
475-
int a = 0;
476475
BOOST_FOREACH(CMasternodePaymentWinner& winner, vWinning)
477476
if(winner.nBlockHeight >= chainActive.Tip()->nHeight-10 && winner.nBlockHeight <= chainActive.Tip()->nHeight + 20)
478-
node->PushMessage("mnw", winner, a);
477+
node->PushMessage("mnw", winner);
479478
}
480479

481480

src/masternodeman.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -320,23 +320,29 @@ CMasternode* CMasternodeMan::FindOldestNotInVec(const std::vector<CTxIn> &vVins)
320320

321321
BOOST_FOREACH(CMasternode &mn, vMasternodes)
322322
{
323+
printf(" -- mn %s\n", mn.vin.ToString().c_str());
323324
mn.Check();
324325
if(!mn.IsEnabled()) continue;
325326

326327
bool found = false;
327328
BOOST_FOREACH(const CTxIn& vin, vVins)
328329
if(mn.vin == vin)
329330
{
331+
printf(" -- mn2 %s\n", vin.ToString().c_str());
330332
found = true;
331333
break;
332334
}
333335

336+
printf(" -- mn %d\n", found);
334337
if(found) continue;
335338

336-
if(pOldestMasternode == NULL || pOldestMasternode->GetMasternodeInputAge() < mn.GetMasternodeInputAge())
339+
if(pOldestMasternode == NULL || pOldestMasternode->GetMasternodeInputAge() < mn.GetMasternodeInputAge()){
340+
printf("got mn %s\n", mn.vin.ToString().c_str());
337341
pOldestMasternode = &mn;
342+
}
338343
}
339344

345+
printf(" -- %d\n", pOldestMasternode != NULL);
340346
return pOldestMasternode;
341347
}
342348

0 commit comments

Comments
 (0)