Spork changes / improvements

- New Command "Spork Active" : Show which sporks report as active
- Cleaned up the spork code and fixed some bugs with defaults
This commit is contained in:
Evan Duffield 2015-06-25 08:17:53 -07:00
parent 94493bee63
commit e3963ea71c
3 changed files with 33 additions and 20 deletions

View File

@ -299,9 +299,11 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew)
BOOST_FOREACH(CMasternodePayee& payee, vecPayments)
{
bool found = false;
BOOST_FOREACH(CTxOut out, txNew.vout)
if(payee.scriptPubKey == out.scriptPubKey && payee.nValue == out.nValue)
BOOST_FOREACH(CTxOut out, txNew.vout){
if(payee.scriptPubKey == out.scriptPubKey && payee.nValue == out.nValue){
found = true;
}
}
if(payee.nVotes >= MNPAYMENTS_SIGNATURES_REQUIRED){
if(found) return true;

View File

@ -165,10 +165,21 @@ Value spork(const Array& params, bool fHelp)
Object ret;
while(it != mapSporksActive.end()) {
if(sporkManager.GetSporkNameByID(it->second.nSporkID) != "Unknown")
ret.push_back(Pair(sporkManager.GetSporkNameByID(it->second.nSporkID), it->second.nValue));
it++;
}
return ret;
} else if(params.size() == 1 && params[0].get_str() == "active"){
std::map<int, CSporkMessage>::iterator it = mapSporksActive.begin();
Object ret;
while(it != mapSporksActive.end()) {
if(sporkManager.GetSporkNameByID(it->second.nSporkID) != "Unknown")
ret.push_back(Pair(sporkManager.GetSporkNameByID(it->second.nSporkID), IsSporkActive(it->second.nSporkID)));
it++;
}
return ret;
} else if (params.size() == 2){
int nSporkID = sporkManager.GetSporkIDByName(params[0].get_str());
if(nSporkID == -1){
@ -189,7 +200,7 @@ Value spork(const Array& params, bool fHelp)
throw runtime_error(
"spork <name> [<value>]\n"
"<name> is the corresponding spork name, or 'show' to show all current spork settings"
"<name> is the corresponding spork name, or 'show' to show all current spork settings, active to show which sporks are active"
"<value> is a epoch datetime to enable or disable spork"
+ HelpRequiringPassphrase());
}

View File

@ -84,9 +84,9 @@ bool IsSporkActive(int nSporkID)
if(nSporkID == SPORK_2_INSTANTX) r = SPORK_2_INSTANTX_DEFAULT;
if(nSporkID == SPORK_3_INSTANTX_BLOCK_FILTERING) r = SPORK_3_INSTANTX_BLOCK_FILTERING_DEFAULT;
if(nSporkID == SPORK_5_MAX_VALUE) r = SPORK_5_MAX_VALUE_DEFAULT;
if(nSporkID == SPORK_7_MASTERNODE_SCANNING) r = SPORK_7_MASTERNODE_SCANNING;
if(nSporkID == SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) r = SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT;
if(nSporkID == SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT) r = SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT;
if(nSporkID == SPORK_7_MASTERNODE_SCANNING) r = SPORK_7_MASTERNODE_SCANNING_DEFAULT;
if(nSporkID == SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT) r = SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT;
if(nSporkID == SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT) r = SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT_DEFAULT;
if(r == 0) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
}