Test feeTX in IsValid

This commit is contained in:
Evan Duffield 2015-07-15 07:18:03 -07:00
parent db080fec22
commit 21769085ec

View File

@ -749,19 +749,14 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
//set time we first saw this prop
budgetProposalBroadcast.nTime = GetAdjustedTime();
mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
std::string strError = "";
if(!budgetProposalBroadcast.IsValid(strError)) {
LogPrintf("mprop - invalid budget proposal - %s\n", strError);
return;
}
mapSeenMasternodeBudgetProposals.insert(make_pair(budgetProposalBroadcast.GetHash(), budgetProposalBroadcast));
if(!IsBudgetCollateralValid(budgetProposalBroadcast.nFeeTXHash, budgetProposalBroadcast.GetHash(), strError)){
LogPrintf("Proposal FeeTX is not valid - %s - %s\n", budgetProposalBroadcast.nFeeTXHash.ToString(), strError);
return;
}
CBudgetProposal budgetProposal(budgetProposalBroadcast);
budget.AddProposal(budgetProposal);
budgetProposalBroadcast.Relay();
@ -818,13 +813,13 @@ void CBudgetManager::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
return;
}
mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
if(!finalizedBudgetBroadcast.IsValid()) {
LogPrintf("fbs - invalid finalized budget\n");
return;
}
mapSeenFinalizedBudgets.insert(make_pair(finalizedBudgetBroadcast.GetHash(), finalizedBudgetBroadcast));
CFinalizedBudget finalizedBudget(finalizedBudgetBroadcast);
budget.AddFinalizedBudget(finalizedBudget);
finalizedBudgetBroadcast.Relay();
@ -1022,6 +1017,10 @@ bool CBudgetProposal::IsValid(std::string& strError)
return false;
}
if(!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError)){
return false;
}
//if proposal doesn't gain traction within 2 weeks, remove it
// nTime not being saved correctly
// if(nTime + (60*60*24*2) < GetAdjustedTime()) {
@ -1436,6 +1435,11 @@ bool CFinalizedBudget::IsValid()
//can only pay out 10% of the possible coins (min value of coins)
if(GetTotalPayout() > budget.GetTotalBudget(nBlockStart)) return false;
std::string strError = "";
if(!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError)){
return false;
}
//TODO: if N cycles old, invalid, invalid
CBlockIndex* pindexPrev = chainActive.Tip();