Fixed prepare -- shouldn't check collateral

This commit is contained in:
Evan Duffield 2015-07-15 15:56:40 -07:00
parent ffed6dc948
commit f139dbbc74
3 changed files with 13 additions and 9 deletions

View File

@ -1000,7 +1000,7 @@ CBudgetProposal::CBudgetProposal(const CBudgetProposal& other)
fValid = true; fValid = true;
} }
bool CBudgetProposal::IsValid(std::string& strError) bool CBudgetProposal::IsValid(std::string& strError, bool fCheckCollateral)
{ {
if(GetYeas()-GetNays() < -(mnodeman.CountEnabled()/10)){ if(GetYeas()-GetNays() < -(mnodeman.CountEnabled()/10)){
strError = "Active removal"; strError = "Active removal";
@ -1017,9 +1017,11 @@ bool CBudgetProposal::IsValid(std::string& strError)
return false; return false;
} }
if(fCheckCollateral){
if(!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError)){ if(!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError)){
return false; 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
@ -1422,7 +1424,7 @@ std::string CFinalizedBudget::GetStatus()
return retBadHashes + retBadPayeeOrAmount; return retBadHashes + retBadPayeeOrAmount;
} }
bool CFinalizedBudget::IsValid() bool CFinalizedBudget::IsValid(bool fCheckCollateral)
{ {
//must be the correct block for payment to happen (once a month) //must be the correct block for payment to happen (once a month)
if(nBlockStart % GetBudgetPaymentCycleBlocks() != 0) return false; if(nBlockStart % GetBudgetPaymentCycleBlocks() != 0) return false;
@ -1436,9 +1438,11 @@ bool CFinalizedBudget::IsValid()
if(GetTotalPayout() > budget.GetTotalBudget(nBlockStart)) return false; if(GetTotalPayout() > budget.GetTotalBudget(nBlockStart)) return false;
std::string strError = ""; std::string strError = "";
if(fCheckCollateral){
if(!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError)){ if(!IsBudgetCollateralValid(nFeeTXHash, GetHash(), strError)){
return false; return false;
} }
}
//TODO: if N cycles old, invalid, invalid //TODO: if N cycles old, invalid, invalid

View File

@ -203,7 +203,7 @@ public:
double GetScore(); double GetScore();
bool HasMinimumRequiredSupport(); bool HasMinimumRequiredSupport();
bool IsValid(); bool IsValid(bool fCheckCollateral=true);
std::string GetName() {return strBudgetName; } std::string GetName() {return strBudgetName; }
std::string GetProposals(); std::string GetProposals();
@ -368,7 +368,7 @@ public:
bool HasMinimumRequiredSupport(); bool HasMinimumRequiredSupport();
std::pair<std::string, std::string> GetVotes(); std::pair<std::string, std::string> GetVotes();
bool IsValid(std::string& strError); bool IsValid(std::string& strError, bool fCheckCollateral=true);
std::string GetName() {return strProposalName; } std::string GetName() {return strProposalName; }
std::string GetURL() {return strURL; } std::string GetURL() {return strURL; }

View File

@ -95,7 +95,7 @@ Value mnbudget(const Array& params, bool fHelp)
CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0); CBudgetProposalBroadcast budgetProposalBroadcast(strProposalName, strURL, nPaymentCount, scriptPubKey, nAmount, nBlockStart, 0);
std::string strError = ""; std::string strError = "";
if(!budgetProposalBroadcast.IsValid(strError)) if(!budgetProposalBroadcast.IsValid(strError, false))
return "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + strError; return "Proposal is not valid - " + budgetProposalBroadcast.GetHash().ToString() + " - " + strError;
std::string cmd = "tx"; std::string cmd = "tx";