mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 22:45:52 +00:00
Updates to local and remote transaction fee factor tracking.
This commit is contained in:
@@ -105,3 +105,50 @@ bool LoadManager::adjust(LoadSource& source, int credits) const
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64 LoadTrack::scaleFee(uint64 fee)
|
||||||
|
{
|
||||||
|
static uint64 midrange(0x00000000FFFFFFFF);
|
||||||
|
int factor = (mLocalTxnLoadFee > mRemoteTxnLoadFee) ? mLocalTxnLoadFee : mRemoteTxnLoadFee;
|
||||||
|
|
||||||
|
if (fee > midrange) // large fee, divide first
|
||||||
|
return (fee >> 16) * factor;
|
||||||
|
else // small fee, multiply first
|
||||||
|
return (fee * factor) >> 16;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadTrack::raiseRemoteFee()
|
||||||
|
{
|
||||||
|
if (mRemoteTxnLoadFee < mLocalTxnLoadFee) // make sure this fee takes effect
|
||||||
|
mRemoteTxnLoadFee = mLocalTxnLoadFee;
|
||||||
|
|
||||||
|
if (mRemoteTxnLoadFee < 268435456) // no more than a million
|
||||||
|
mRemoteTxnLoadFee += (mRemoteTxnLoadFee >> 4); // increment by 1/16th
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadTrack::lowerRemoteFee()
|
||||||
|
{
|
||||||
|
mLocalTxnLoadFee -= (mLocalTxnLoadFee >> 4); // reduce by 1/16th
|
||||||
|
|
||||||
|
if (mLocalTxnLoadFee < 256)
|
||||||
|
mLocalTxnLoadFee = 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadTrack::raiseLocalFee()
|
||||||
|
{
|
||||||
|
if (mLocalTxnLoadFee < mLocalTxnLoadFee) // make sure this fee takes effect
|
||||||
|
mLocalTxnLoadFee = mLocalTxnLoadFee;
|
||||||
|
|
||||||
|
if (mLocalTxnLoadFee < 268435456) // no more than a million
|
||||||
|
mLocalTxnLoadFee += (mLocalTxnLoadFee >> 4); // increment by 1/16th
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadTrack::lowerLocalFee()
|
||||||
|
{
|
||||||
|
mLocalTxnLoadFee -= (mLocalTxnLoadFee >> 4); // reduce by 1/16th
|
||||||
|
|
||||||
|
if (mLocalTxnLoadFee < 256)
|
||||||
|
mLocalTxnLoadFee = 256;
|
||||||
|
}
|
||||||
|
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
class LoadSource
|
class LoadSource
|
||||||
{ // a single endpoint that can impose load
|
{ // a single endpoint that can impose load
|
||||||
friend class LoadManager;
|
friend class LoadManager;
|
||||||
@@ -60,4 +62,29 @@ public:
|
|||||||
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 LoadTrack
|
||||||
|
{ // structure that tracks our current fee/load schedule
|
||||||
|
protected:
|
||||||
|
|
||||||
|
uint32 mLocalTxnLoadFee; // Scale factor, 256 = normal fee
|
||||||
|
uint32 mRemoteTxnLoadFee; // Scale factor, 256 = normal fee
|
||||||
|
uint32 mPeerLoadSchedule; // Schedule setting, 0 = normal schedule
|
||||||
|
uint32 mClientLoadSchedule; // Schedule setting, 0 = normal schedule
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
LoadTrack() : mLocalTxnLoadFee(256), mRemoteTxnLoadFee(256), mPeerLoadSchedule(0), mClientLoadSchedule(0)
|
||||||
|
{ ; }
|
||||||
|
|
||||||
|
uint64 scaleFee(uint64 fee);
|
||||||
|
|
||||||
|
void raiseRemoteFee();
|
||||||
|
void raiseLocalFee();
|
||||||
|
void lowerRemoteFee();
|
||||||
|
void lowerLocalFee();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
Reference in New Issue
Block a user