From 3b7bf171ed4389322963359802f7f7c7a0079d7c Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Wed, 5 Dec 2012 15:45:07 -0800 Subject: [PATCH] Structure to charge and credit for load types. --- src/cpp/ripple/LoadManager.cpp | 3 ++- src/cpp/ripple/LoadManager.h | 8 ++------ src/cpp/ripple/LoadTypes.h | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 src/cpp/ripple/LoadTypes.h diff --git a/src/cpp/ripple/LoadManager.cpp b/src/cpp/ripple/LoadManager.cpp index 5f2f60f2cc..0b040c5ad5 100644 --- a/src/cpp/ripple/LoadManager.cpp +++ b/src/cpp/ripple/LoadManager.cpp @@ -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); diff --git a/src/cpp/ripple/LoadManager.h b/src/cpp/ripple/LoadManager.h index 9280f3b530..3b3de6f151 100644 --- a/src/cpp/ripple/LoadManager.h +++ b/src/cpp/ripple/LoadManager.h @@ -59,7 +59,7 @@ public: bool shouldWarn(LoadSource&) const; bool shouldCutoff(LoadSource&) const; - bool adjust(LoadSource&, int credits) const; // return value: false = balance okay, true = warn/cutoff + bool adjust(LoadSource&, int credits) const; // return value: false=balance okay, true=warn/cutoff }; class LoadFeeTrack @@ -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); diff --git a/src/cpp/ripple/LoadTypes.h b/src/cpp/ripple/LoadTypes.h new file mode 100644 index 0000000000..a2232174c7 --- /dev/null +++ b/src/cpp/ripple/LoadTypes.h @@ -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