Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2012-12-05 18:02:58 -08:00
8 changed files with 70 additions and 30 deletions

View File

@@ -210,6 +210,24 @@ Json::Value RPCParser::parseLogin(const Json::Value& jvParams)
return jvRequest;
}
// log_level: Get log levels
// log_level <severity>: Set master log level to the specified severity
// log_level <partition> <severity>: Set specified partition to specified severity
Json::Value RPCParser::parseLogLevel(const Json::Value& jvParams)
{
Json::Value jvRequest(Json::objectValue);
if (jvParams.size() == 1)
jvRequest["severity"] = jvParams[0u].asString();
else if (jvParams.size() == 2)
{
jvRequest["partition"] = jvParams[0u].asString();
jvRequest["severity"] = jvParams[1u].asString();
}
return jvRequest;
}
// owner_info <account>|<nickname>|<account_public_key>
// owner_info <seed>|<pass_phrase>|<key> [<index>]
Json::Value RPCParser::parseOwnerInfo(const Json::Value& jvParams)
@@ -405,7 +423,7 @@ Json::Value RPCParser::parseCommand(std::string strMethod, Json::Value jvParams)
{ "ledger_current", &RPCParser::parseAsIs, 0, 0 },
// { "ledger_entry", &RPCParser::parseLedgerEntry, -1, -1 },
// { "ledger_header", &RPCParser::parseLedgerHeader, -1, -1 },
// { "log_level", &RPCParser::parseLogLevel, 0, 2 },
{ "log_level", &RPCParser::parseLogLevel, 0, 2 },
{ "logrotate", &RPCParser::parseAsIs, 0, 0 },
// { "nickname_info", &RPCParser::parseNicknameInfo, 1, 1 },
{ "owner_info", &RPCParser::parseOwnerInfo, 1, 2 },

View File

@@ -23,6 +23,7 @@ protected:
Json::Value parseGetCounts(const Json::Value& jvParams);
Json::Value parseLedger(const Json::Value& jvParams);
Json::Value parseLogin(const Json::Value& jvParams);
Json::Value parseLogLevel(const Json::Value& jvParams);
Json::Value parseOwnerInfo(const Json::Value& jvParams);
Json::Value parseRandom(const Json::Value& jvParams);
Json::Value parseSubmit(const Json::Value& jvParams);

View File

@@ -70,6 +70,7 @@ bool LoadManager::shouldWarn(LoadSource& source) const
canonicalize(source, now);
if (source.isPrivileged() || (source.mBalance < mDebitWarn) || (source.mLastWarning == now))
return false;
source.mLastWarning = now;
return true;
}
@@ -84,7 +85,7 @@ bool LoadManager::shouldCutoff(LoadSource& source) const
}
bool LoadManager::adjust(LoadSource& source, int credits) const
{
{ // return: true = need to warn/cutoff
time_t now = time(NULL);
boost::mutex::scoped_lock sl(mLock);

View File

@@ -73,14 +73,10 @@ protected:
uint32 mLocalTxnLoadFee; // Scale factor, lftNormalFee = normal fee
uint32 mRemoteTxnLoadFee; // Scale factor, lftNormalFee = normal fee
uint32 mPeerLoadSchedule; // Schedule setting, 0 = normal schedule
uint32 mClientLoadSchedule; // Schedule setting, 0 = normal schedule
public:
LoadFeeTrack()
: mLocalTxnLoadFee(lftNormalFee), mRemoteTxnLoadFee(lftNormalFee), mPeerLoadSchedule(0), mClientLoadSchedule(0)
{ ; }
LoadFeeTrack() : mLocalTxnLoadFee(lftNormalFee), mRemoteTxnLoadFee(lftNormalFee) { ; }
uint64 scaleFee(uint64 fee);

View File

@@ -0,0 +1,27 @@
#ifndef LOADTYPES__H
#define LOADTYPES__H
enum LoadType
{ // types of load that can be placed on the server
// Bad things
LT_InvalidRequest, // A request that we can immediately tell is invalid
LT_RequestNoReply, // A request that we cannot satisfy
LT_InvalidSignature, // An object whose signature we had to check and it failed
LT_UnwantedData, // Data we have no use for
// Good things
LT_NewTrusted, // A new transaction/validation/proposal we trust
LT_NewTransaction, // A new, valid transaction
LT_NeededData, // Data we requested
// Requests
LT_RequestData, // A request that is hard to satisfy, disk access
LT_CheapQuery, // A query that is trivial, cached data
};
static const int LoadCategoryDisk = 1;
static const int LoadCategoryCPU = 2;
static const int LoadCateogryNetwork = 4;
#endif

View File

@@ -1548,52 +1548,47 @@ Json::Value RPCHandler::doGetCounts(Json::Value jvRequest)
return ret;
}
Json::Value RPCHandler::doLogLevel(Json::Value params)
Json::Value RPCHandler::doLogLevel(Json::Value jvRequest)
{
// log_level
if (params.size() == 0)
if (!jvRequest.isMember("severity"))
{ // get log severities
Json::Value ret = Json::objectValue;
ret["base"] = Log::severityToString(Log::getMinSeverity());
Json::Value ret(Json::objectValue);
Json::Value lev(Json::objectValue);
lev["base"] = Log::severityToString(Log::getMinSeverity());
std::vector< std::pair<std::string, std::string> > logTable = LogPartition::getSeverities();
typedef std::pair<std::string, std::string> stringPair;
BOOST_FOREACH(const stringPair& it, logTable)
ret[it.first] = it.second;
lev[it.first] = it.second;
ret["levels"] = lev;
return ret;
}
// log_level severity
if (params.size() == 1)
{ // set base log severity
LogSeverity sv = Log::stringToSeverity(params[0u].asString());
LogSeverity sv = Log::stringToSeverity(jvRequest["severity"].asString());
if (sv == lsINVALID)
return rpcError(rpcINVALID_PARAMS);
// log_level severity
if (!jvRequest.isMember("partition"))
{ // set base log severity
Log::setMinSeverity(sv, true);
return rpcError(rpcSUCCESS);
}
// log_level partition severity base?
if (params.size() == 2)
if (jvRequest.isMember("partition"))
{ // set partition severity
LogSeverity sv = Log::stringToSeverity(params[1u].asString());
if (sv == lsINVALID)
return rpcError(rpcINVALID_PARAMS);
if (params[2u].asString() == "base")
std::string partition(jvRequest["partition"].asString());
if (boost::iequals(partition, "base"))
Log::setMinSeverity(sv,false);
else if (!LogPartition::setSeverity(params[0u].asString(), sv))
else if (!LogPartition::setSeverity(partition, sv))
return rpcError(rpcINVALID_PARAMS);
return rpcError(rpcSUCCESS);
}
assert(false);
return rpcError(rpcINVALID_PARAMS);
}

View File

@@ -58,6 +58,7 @@
FIELD(FirstLedgerSequence, UINT32, 26)
FIELD(LastLedgerSequence, UINT32, 27)
FIELD(TransactionIndex, UINT32, 28)
FIELD(OperationLimit, UINT32, 29)
// 64-bit integers
FIELD(IndexNext, UINT64, 1)

View File

@@ -10,6 +10,7 @@ std::map<std::string, TransactionFormat*> TransactionFormat::byName;
<< SOElement(sfAccount, SOE_REQUIRED) \
<< SOElement(sfSequence, SOE_REQUIRED) \
<< SOElement(sfFee, SOE_REQUIRED) \
<< SOElement(sfOperationLimit, SOE_OPTIONAL) \
<< SOElement(sfSigningPubKey, SOE_REQUIRED) \
<< SOElement(sfTxnSignature, SOE_OPTIONAL)