mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Optimize processing of a (potentially) new MN:
- Move heavy `IsVinAssociatedWithPubkey` deep inside of `CheckInputsAndAdd` to be actually executed only once per masternode and only after much simpler checks were executed; - Verify `GetInputAge` (it uses cache) before trying to enter `AcceptToMemoryPool` (which hash many ifs and checks inside).
This commit is contained in:
parent
38b532ae6d
commit
87ad368643
@ -462,6 +462,14 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDos)
|
||||
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;
|
||||
CMutableTransaction tx = CMutableTransaction();
|
||||
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);
|
||||
// maybe we miss few blocks, let this mnb to be checked again later
|
||||
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());
|
||||
masternodeSync.mapSeenSyncMNB.erase(GetHash());
|
||||
|
||||
// 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(vin, pubkey)) {
|
||||
LogPrintf("CMasternodeMan::CheckInputsAndAdd - Got mismatched pubkey and vin\n");
|
||||
nDos = 33;
|
||||
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);
|
||||
CMasternode mn(*this);
|
||||
mnodeman.Add(mn);
|
||||
|
@ -840,14 +840,6 @@ bool CMasternodeMan::CheckMnbAndUpdateMasternodeList(CMasternodeBroadcast mnb, i
|
||||
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
|
||||
// - this is checked later by .check() in many places and by ThreadCheckDarkSendPool()
|
||||
if(mnb.CheckInputsAndAdd(nDos)) {
|
||||
|
Loading…
Reference in New Issue
Block a user