GetMinCollateralFee should not validate object type (#1050)
* GetMinCollateralFee should not validate object type, it should be IsValidLocally's job * Explicitly set 0 fee for known free objects, set fee to MAX_MONEY for unknown one
This commit is contained in:
parent
4316b4e277
commit
a650165318
@ -856,6 +856,15 @@ bool CGovernanceObject::IsValidLocally(const CBlockIndex* pindex, std::string& s
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch(nObjectType) {
|
||||||
|
case GOVERNANCE_OBJECT_PROPOSAL:
|
||||||
|
case GOVERNANCE_OBJECT_TRIGGER:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strError = strprintf("Invalid object type %d", nObjectType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// IF ABSOLUTE NO COUNT (NO-YES VALID VOTES) IS MORE THAN 10% OF THE NETWORK MASTERNODES, OBJ IS INVALID
|
// IF ABSOLUTE NO COUNT (NO-YES VALID VOTES) IS MORE THAN 10% OF THE NETWORK MASTERNODES, OBJ IS INVALID
|
||||||
|
|
||||||
if(GetAbsoluteNoCount(VOTE_SIGNAL_VALID) > mnodeman.CountEnabled(MIN_GOVERNANCE_PEER_PROTO_VERSION)/10) {
|
if(GetAbsoluteNoCount(VOTE_SIGNAL_VALID) > mnodeman.CountEnabled(MIN_GOVERNANCE_PEER_PROTO_VERSION)/10) {
|
||||||
@ -921,37 +930,18 @@ bool CGovernanceObject::IsValidLocally(const CBlockIndex* pindex, std::string& s
|
|||||||
|
|
||||||
CAmount CGovernanceObject::GetMinCollateralFee()
|
CAmount CGovernanceObject::GetMinCollateralFee()
|
||||||
{
|
{
|
||||||
CAmount nMinFee = 0;
|
|
||||||
// Only 1 type has a fee for the moment but switch statement allows for future object types
|
// Only 1 type has a fee for the moment but switch statement allows for future object types
|
||||||
switch(nObjectType) {
|
switch(nObjectType) {
|
||||||
case GOVERNANCE_OBJECT_PROPOSAL:
|
case GOVERNANCE_OBJECT_PROPOSAL: return GOVERNANCE_PROPOSAL_FEE_TX;
|
||||||
nMinFee = GOVERNANCE_PROPOSAL_FEE_TX;
|
case GOVERNANCE_OBJECT_TRIGGER: return 0;
|
||||||
break;
|
default: return MAX_MONEY;
|
||||||
case GOVERNANCE_OBJECT_TRIGGER:
|
|
||||||
nMinFee = 0;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
std::ostringstream ostr;
|
|
||||||
ostr << "CGovernanceObject::GetMinCollateralFee ERROR: Unknown governance object type: " << nObjectType;
|
|
||||||
throw std::runtime_error(ostr.str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nMinFee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CGovernanceObject::IsCollateralValid(std::string& strError)
|
bool CGovernanceObject::IsCollateralValid(std::string& strError)
|
||||||
{
|
{
|
||||||
CAmount nMinFee = 0;
|
strError = "";
|
||||||
try {
|
CAmount nMinFee = GetMinCollateralFee();
|
||||||
nMinFee = GetMinCollateralFee();
|
|
||||||
}
|
|
||||||
catch(std::exception& e) {
|
|
||||||
strError = e.what();
|
|
||||||
LogPrintf("CGovernanceObject::IsCollateralValid ERROR An exception occurred - %s\n", e.what());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint256 nExpectedHash = GetHash();
|
uint256 nExpectedHash = GetHash();
|
||||||
|
|
||||||
CTransaction txCollateral;
|
CTransaction txCollateral;
|
||||||
|
Loading…
Reference in New Issue
Block a user