src/rpcmisc.cpp
/*
    Used for updating/reading spork settings on the network
*/
Used for updating/reading spork settings on the network
Used for updating / reading spork settings on the network
Value spork(const Array& params, bool fHelp)
{
    if (params.size() == 1 && params[0].get_str() == "show") {
        Object ret;
        for (int nSporkID = SPORK_START; nSporkID <= SPORK_END; nSporkID++) {
            if (sporkManager.GetSporkNameByID(nSporkID) != "Unknown")
                ret.push_back(Pair(sporkManager.GetSporkNameByID(nSporkID), GetSporkValue(nSporkID)));
        }
        return ret;
    } else if (params.size() == 1 && params[0].get_str() == "active") {
        Object ret;
        for (int nSporkID = SPORK_START; nSporkID <= SPORK_END; nSporkID++) {
            if (sporkManager.GetSporkNameByID(nSporkID) != "Unknown")
                ret.push_back(Pair(sporkManager.GetSporkNameByID(nSporkID), IsSporkActive(nSporkID)));
        }
        return ret;
    } else if (params.size() == 2) {
        int nSporkID = sporkManager.GetSporkIDByName(params[0].get_str());
        if (nSporkID == -1) {
            return "Invalid spork name";
        }
        int64_t nValue = params[1].get_int();
        if (sporkManager.UpdateSpork(nSporkID, nValue)) {
            ExecuteSpork(nSporkID, nValue);
            return "success";
        } else {
            return "failure";
        }
    }
    throw runtime_error(
        "spork <name> [<value>]\n"
        "<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());
}
Value spork ( const Array & params , bool fHelp ) { if ( params . size ( ) == 1 && params [ 0 ] . get_str ( ) == " " ) { Object ret ; for ( int nSporkID = SPORK_START ; nSporkID <= SPORK_END ; nSporkID ++ ) { if ( sporkManager . GetSporkNameByID ( nSporkID ) != " " ) ret . push_back ( Pair ( sporkManager . GetSporkNameByID ( nSporkID ) , GetSporkValue ( nSporkID ) ) ) ; } return ret ; } else if ( params . size ( ) == 1 && params [ 0 ] . get_str ( ) == " " ) { Object ret ; for ( int nSporkID = SPORK_START ; nSporkID <= SPORK_END ; nSporkID ++ ) { if ( sporkManager . GetSporkNameByID ( nSporkID ) != " " ) ret . push_back ( Pair ( sporkManager . GetSporkNameByID ( nSporkID ) , IsSporkActive ( nSporkID ) ) ) ; } return ret ; } else if ( params . size ( ) == 2 ) { int nSporkID = sporkManager . GetSporkIDByName ( params [ 0 ] . get_str ( ) ) ; if ( nSporkID == -1 ) { return " " ; } int64_t nValue = params [ 1 ] . get_int ( ) ; if ( sporkManager . UpdateSpork ( nSporkID , nValue ) ) { ExecuteSpork ( nSporkID , nValue ) ; return " " ; } else { return " " ; } } throw runtime_error ( " \n " " " " " + HelpRequiringPassphrase ( ) ) ; }
Used for updating/reading spork settings on the network
Used for updating / reading spork settings on the network
// SPORK VALUE //broadcast new spork