rippled
Loading...
Searching...
No Matches
LoadFeeTrack.h
1#pragma once
2
3#include <xrpl/basics/Log.h>
4#include <xrpl/beast/utility/Journal.h>
5#include <xrpl/protocol/XRPAmount.h>
6
7#include <algorithm>
8#include <cstdint>
9#include <mutex>
10
11namespace xrpl {
12
13struct Fees;
14
24class LoadFeeTrack final
25{
26public:
35
36 ~LoadFeeTrack() = default;
37
38 void
40 {
41 JLOG(j_.trace()) << "setRemoteFee: " << f;
44 }
45
48 {
50 return remoteTxnLoadFee_;
51 }
52
55 {
57 return localTxnLoadFee_;
58 }
59
62 {
64 return clusterTxnLoadFee_;
65 }
66
69 {
70 return lftNormalFee;
71 }
72
79
88
89 void
91 {
92 JLOG(j_.trace()) << "setClusterFee: " << fee;
95 }
96
97 bool
99 bool
101
102 bool
104 {
106 return (raiseCount_ != 0) || (localTxnLoadFee_ != lftNormalFee);
107 }
108
109 bool
111 {
114 }
115
116private:
117 static std::uint32_t constexpr lftNormalFee = 256; // 256 is the minimum/normal load factor
118 static std::uint32_t constexpr lftFeeIncFraction = 4; // increase fee by 1/4
119 static std::uint32_t constexpr lftFeeDecFraction = 4; // decrease fee by 1/4
120 static std::uint32_t constexpr lftFeeMax = lftNormalFee * 1000000;
121
124
125 std::uint32_t localTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
126 std::uint32_t remoteTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
127 std::uint32_t clusterTxnLoadFee_; // Scale factor, lftNormalFee = normal fee
129};
130
131//------------------------------------------------------------------------------
132
133// Scale using load as well as base rate
135scaleFeeLoad(XRPAmount fee, LoadFeeTrack const& feeTrack, Fees const& fees, bool bUnlimited);
136
137} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
static Sink & getNullSink()
Returns a Sink which does nothing.
Stream trace() const
Severity stream access functions.
Definition Journal.h:294
Manages the current fee schedule.
static std::uint32_t constexpr lftFeeDecFraction
~LoadFeeTrack()=default
static std::uint32_t constexpr lftFeeIncFraction
std::uint32_t clusterTxnLoadFee_
void setRemoteFee(std::uint32_t f)
std::uint32_t getClusterFee() const
std::uint32_t getLocalFee() const
std::uint32_t remoteTxnLoadFee_
static std::uint32_t constexpr lftNormalFee
std::uint32_t getRemoteFee() const
std::uint32_t getLoadFactor() const
void setClusterFee(std::uint32_t fee)
bool isLoadedLocal() const
std::uint32_t getLoadBase() const
std::uint32_t localTxnLoadFee_
std::uint32_t raiseCount_
beast::Journal const j_
bool isLoadedCluster() const
std::pair< std::uint32_t, std::uint32_t > getScalingFactors() const
LoadFeeTrack(beast::Journal journal=beast::Journal(beast::Journal::getNullSink()))
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:5
XRPAmount scaleFeeLoad(XRPAmount fee, LoadFeeTrack const &feeTrack, Fees const &fees, bool bUnlimited)
Reflects the fee settings for a particular ledger.