Annotate some core classes

This commit is contained in:
Vinnie Falco
2013-06-23 19:31:16 -07:00
parent fca16f5c71
commit 5c21ce5b3c
12 changed files with 125 additions and 99 deletions

View File

@@ -4,14 +4,24 @@
*/
//==============================================================================
#ifndef RIPPLE_ILOADFEETRACK_H
#define RIPPLE_ILOADFEETRACK_H
#ifndef RIPPLE_ILOADFEETRACK_RIPPLEHEADER
#define RIPPLE_ILOADFEETRACK_RIPPLEHEADER
/** Tracks the current fee and load schedule.
/** Manages the current fee schedule.
The "base" fee is the cost to send a reference transaction under no load,
expressed in millionths of one XRP.
The "load" fee is how much the local server currently charges to send a
reference transaction. This fee fluctuates based on the load of the
server.
*/
// VFALCO TODO Rename "load" to "current".
class ILoadFeeTrack
{
public:
/** Create a new tracker.
*/
static ILoadFeeTrack* New ();
virtual ~ILoadFeeTrack () { }
@@ -22,20 +32,20 @@ public:
// Scale using load as well as base rate
virtual uint64 scaleFeeLoad (uint64 fee, uint64 baseFee, uint32 referenceFeeUnits, bool bAdmin) = 0;
virtual uint32 getRemoteFee () = 0;
virtual uint32 getLocalFee () = 0;
// VFALCO NOTE These appear to be unused, so I'm hiding the declarations.
//
//virtual uint32 getRemoteFee () = 0;
//virtual uint32 getLocalFee () = 0;
//virtual void setRemoteFee (uint32) = 0;
virtual uint32 getLoadBase () = 0;
virtual uint32 getLoadFactor () = 0;
virtual Json::Value getJson (uint64 baseFee, uint32 referenceFeeUnits) = 0;
virtual void setRemoteFee (uint32) = 0;
virtual bool raiseLocalFee () = 0;
virtual bool lowerLocalFee () = 0;
virtual bool isLoaded () = 0;
};
#endif
// vim:ts=4

View File

@@ -152,7 +152,7 @@ Json::Value JobQueue::getJson (int)
return ret;
}
int JobQueue::isOverloaded ()
bool JobQueue::isOverloaded ()
{
int count = 0;
boost::mutex::scoped_lock sl (mJobLock);
@@ -161,7 +161,7 @@ int JobQueue::isOverloaded ()
if (mJobLoads[i].isOver ())
++count;
return count;
return count > 0;
}
void JobQueue::shutdown ()

View File

@@ -38,7 +38,7 @@ public:
return LoadEvent::autoptr (new LoadEvent (mJobLoads[t], name, true));
}
int isOverloaded ();
bool isOverloaded ();
Json::Value getJson (int c = 0);
private:

View File

@@ -8,30 +8,6 @@ class LoadManager;
class LoadFeeTrack : public ILoadFeeTrack
{
private:
static const int lftNormalFee = 256; // 256 is the minimum/normal load factor
static const int lftFeeIncFraction = 16; // increase fee by 1/16
static const int lftFeeDecFraction = 4; // decrease fee by 1/4
static const int lftFeeMax = lftNormalFee * 1000000;
uint32 mLocalTxnLoadFee; // Scale factor, lftNormalFee = normal fee
uint32 mRemoteTxnLoadFee; // Scale factor, lftNormalFee = normal fee
int raiseCount;
boost::mutex mLock;
// VFALCO TODO Move this function to some "math utilities" file
// compute (value)*(mul)/(div) - avoid overflow but keep precision
uint64 mulDiv (uint64 value, uint32 mul, uint64 div)
{
static uint64 boundary = (0x00000000FFFFFFFF);
if (value > boundary) // Large value, avoid overflow
return (value / div) * mul;
else // Normal value, preserve accuracy
return (value * mul) / div;
}
public:
LoadFeeTrack ()
: mLocalTxnLoadFee (lftNormalFee)
@@ -171,6 +147,33 @@ public:
return j;
}
private:
// VFALCO TODO Move this function to some "math utilities" file
// compute (value)*(mul)/(div) - avoid overflow but keep precision
uint64 mulDiv (uint64 value, uint32 mul, uint64 div)
{
// VFALCO TODO replace with beast::literal64bitUnsigned ()
//
static uint64 boundary = (0x00000000FFFFFFFF);
if (value > boundary) // Large value, avoid overflow
return (value / div) * mul;
else // Normal value, preserve accuracy
return (value * mul) / div;
}
private:
static const int lftNormalFee = 256; // 256 is the minimum/normal load factor
static const int lftFeeIncFraction = 16; // increase fee by 1/16
static const int lftFeeDecFraction = 4; // decrease fee by 1/4
static const int lftFeeMax = lftNormalFee * 1000000;
uint32 mLocalTxnLoadFee; // Scale factor, lftNormalFee = normal fee
uint32 mRemoteTxnLoadFee; // Scale factor, lftNormalFee = normal fee
int raiseCount;
boost::mutex mLock;
};
//------------------------------------------------------------------------------

View File

@@ -4,8 +4,8 @@
*/
//==============================================================================
#ifndef RIPPLE_LOADMONITOR_H
#define RIPPLE_LOADMONITOR_H
#ifndef RIPPLE_LOADMONITOR_RIPPLEHEADER
#define RIPPLE_LOADMONITOR_RIPPLEHEADER
// Monitors load levels and response times