Merge pull request #800 from UdjinM6/fixCheckInputsAndAdd

Optimize processing of a (potentially) new MN
This commit is contained in:
Holger Schinzel 2016-05-24 07:20:53 +02:00
commit 3e15bf47d0
2 changed files with 16 additions and 14 deletions

View File

@ -462,6 +462,14 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDos)
else mnodeman.Remove(pmn->vin); else mnodeman.Remove(pmn->vin);
} }
if(GetInputAge(vin) < Params().GetConsensus().nMasternodeMinimumConfirmations){
LogPrintf("CMasternodeBroadcast::CheckInputsAndAdd - Input must have at least %d confirmations\n", Params().GetConsensus().nMasternodeMinimumConfirmations);
// maybe we miss few blocks, let this mnb to be checked again later
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());
masternodeSync.mapSeenSyncMNB.erase(GetHash());
return false;
}
CValidationState state; CValidationState state;
CMutableTransaction tx = CMutableTransaction(); CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(999.99*COIN, darkSendPool.collateralPubKey); CTxOut vout = CTxOut(999.99*COIN, darkSendPool.collateralPubKey);
@ -485,13 +493,14 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDos)
} }
} }
LogPrint("masternode", "CMasternodeBroadcast::CheckInputsAndAdd - Accepted Masternode entry\n"); LogPrint("masternode", "CMasternodeBroadcast::CheckInputsAndAdd - Accepted Masternode entry to mempool (dry-run mode)\n");
if(GetInputAge(vin) < Params().GetConsensus().nMasternodeMinimumConfirmations){
LogPrintf("CMasternodeBroadcast::CheckInputsAndAdd - Input must have at least %d confirmations\n", Params().GetConsensus().nMasternodeMinimumConfirmations); // make sure the vout that was signed is related to the transaction that spawned the Masternode
// maybe we miss few blocks, let this mnb to be checked again later // - this is expensive, so it's only done once per Masternode
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash()); if(!darkSendSigner.IsVinAssociatedWithPubkey(vin, pubkey)) {
masternodeSync.mapSeenSyncMNB.erase(GetHash()); LogPrintf("CMasternodeMan::CheckInputsAndAdd - Got mismatched pubkey and vin\n");
nDos = 33;
return false; return false;
} }
@ -515,6 +524,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDos)
} }
} }
} }
LogPrintf("CMasternodeBroadcast::CheckInputsAndAdd - Got NEW Masternode entry - %s - %s - %s - %lli \n", GetHash().ToString(), addr.ToString(), vin.ToString(), sigTime); LogPrintf("CMasternodeBroadcast::CheckInputsAndAdd - Got NEW Masternode entry - %s - %s - %s - %lli \n", GetHash().ToString(), addr.ToString(), vin.ToString(), sigTime);
CMasternode mn(*this); CMasternode mn(*this);
mnodeman.Add(mn); mnodeman.Add(mn);

View File

@ -840,14 +840,6 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CMasternodeBroadcast mnb, i
return false; return false;
} }
// make sure the vout that was signed is related to the transaction that spawned the Masternode
// - this is expensive, so it's only done once per Masternode
if(!darkSendSigner.IsVinAssociatedWithPubkey(mnb.vin, mnb.pubkey)) {
LogPrintf("CMasternodeMan::CheckMnbAndUpdateMasternodeList - Got mismatched pubkey and vin\n");
nDos = 33;
return false;
}
// make sure it's still unspent // make sure it's still unspent
// - this is checked later by .check() in many places and by ThreadCheckDarkSendPool() // - this is checked later by .check() in many places and by ThreadCheckDarkSendPool()
if(mnb.CheckInputsAndAdd(nDos)) { if(mnb.CheckInputsAndAdd(nDos)) {