Load types.

This commit is contained in:
JoelKatz
2012-12-09 20:37:57 -08:00
parent 92ffca7f42
commit b1dd6c2523
2 changed files with 60 additions and 2 deletions

View File

@@ -1,5 +1,22 @@
#include "LoadManager.h"
LoadManager::LoadManager(int creditRate, int creditLimit, int debitWarn, int debitLimit) :
mCreditRate(creditRate), mCreditLimit(creditLimit), mDebitWarn(debitWarn), mDebitLimit(debitLimit)
{
addLoadCost(LoadCost(LT_InvalidRequest, 10, LC_CPU | LC_Network));
addLoadCost(LoadCost(LT_RequestNoReply, 1, LC_CPU | LC_Disk));
addLoadCost(LoadCost(LT_InvalidSignature, 100, LC_CPU));
addLoadCost(LoadCost(LT_UnwantedData, 5, LC_CPU | LC_Network));
addLoadCost(LoadCost(LT_NewTrusted, 10, 0));
addLoadCost(LoadCost(LT_NewTransaction, 2, 0));
addLoadCost(LoadCost(LT_NeededData, 10, 0));
addLoadCost(LoadCost(LT_RequestData, 5, LC_Disk | LC_Network));
addLoadCost(LoadCost(LT_CheapQuery, 1, LC_CPU));
}
int LoadManager::getCreditRate() const
{
boost::mutex::scoped_lock sl(mLock);