rippled
Loading...
Searching...
No Matches
LoadFeeTrack.h
1#ifndef XRPL_CORE_LOADFEETRACK_H_INCLUDED
2#define XRPL_CORE_LOADFEETRACK_H_INCLUDED
3
4#include <xrpl/basics/Log.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/protocol/XRPAmount.h>
7
8#include <algorithm>
9#include <cstdint>
10#include <mutex>
11
12namespace ripple {
13
14struct Fees;
15
25class LoadFeeTrack final
26{
27public:
37
38 ~LoadFeeTrack() = default;
39
40 void
42 {
43 JLOG(j_.trace()) << "setRemoteFee: " << f;
46 }
47
50 {
52 return remoteTxnLoadFee_;
53 }
54
57 {
59 return localTxnLoadFee_;
60 }
61
64 {
66 return clusterTxnLoadFee_;
67 }
68
71 {
72 return lftNormalFee;
73 }
74
82
92
93 void
95 {
96 JLOG(j_.trace()) << "setClusterFee: " << fee;
99 }
100
101 bool
103 bool
105
106 bool
108 {
110 return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee);
111 }
112
113 bool
115 {
117 return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee) ||
119 }
120
121private:
122 static std::uint32_t constexpr lftNormalFee =
123 256; // 256 is the minimum/normal load factor
125 4; // increase fee by 1/4
127 4; // decrease fee by 1/4
128 static std::uint32_t constexpr lftFeeMax = lftNormalFee * 1000000;
129
132
133 std::uint32_t localTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
134 std::uint32_t remoteTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
136 clusterTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
138};
139
140//------------------------------------------------------------------------------
141
142// Scale using load as well as base rate
145 XRPAmount fee,
146 LoadFeeTrack const& feeTrack,
147 Fees const& fees,
148 bool bUnlimited);
149
150} // namespace ripple
151
152#endif
A generic endpoint for log messages.
Definition Journal.h:41
static Sink & getNullSink()
Returns a Sink which does nothing.
Stream trace() const
Severity stream access functions.
Definition Journal.h:303
Manages the current fee schedule.
std::uint32_t getClusterFee() const
static std::uint32_t constexpr lftFeeIncFraction
bool isLoadedCluster() const
beast::Journal const j_
static std::uint32_t constexpr lftNormalFee
std::uint32_t raiseCount_
void setRemoteFee(std::uint32_t f)
bool isLoadedLocal() const
std::uint32_t localTxnLoadFee_
std::uint32_t remoteTxnLoadFee_
std::uint32_t getLocalFee() const
std::uint32_t getLoadBase() const
LoadFeeTrack(beast::Journal journal=beast::Journal(beast::Journal::getNullSink()))
std::pair< std::uint32_t, std::uint32_t > getScalingFactors() const
std::uint32_t getRemoteFee() const
static std::uint32_t constexpr lftFeeDecFraction
std::uint32_t getLoadFactor() const
void setClusterFee(std::uint32_t fee)
std::uint32_t clusterTxnLoadFee_
static std::uint32_t constexpr lftFeeMax
T make_pair(T... args)
T max(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
XRPAmount scaleFeeLoad(XRPAmount fee, LoadFeeTrack const &feeTrack, Fees const &fees, bool bUnlimited)
Reflects the fee settings for a particular ledger.