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