From 21769085ec809940b8aa25d6f460fd3695622d22 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Wed, 15 Jul 2015 07:18:03 -0700 Subject: [PATCH] Test feeTX in IsValid --- src/masternode-budget.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/masternode-budget.cpp b/src/masternode-budget.cpp index 0de618e202..453bee9dda 100644 --- a/src/masternode-budget.cpp +++ b/src/masternode-budget.cpp @@ -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();