rippled
Loading...
Searching...
No Matches
Entry.h
1#ifndef XRPL_RESOURCE_ENTRY_H_INCLUDED
2#define XRPL_RESOURCE_ENTRY_H_INCLUDED
3
4#include <xrpl/basics/DecayingSample.h>
5#include <xrpl/beast/clock/abstract_clock.h>
6#include <xrpl/beast/core/List.h>
7#include <xrpl/beast/utility/instrumentation.h>
8#include <xrpl/resource/detail/Key.h>
9#include <xrpl/resource/detail/Tuning.h>
10
11namespace ripple {
12namespace Resource {
13
15
16// An entry in the table
17// VFALCO DEPRECATED using boost::intrusive list
18struct Entry : public beast::List<Entry>::Node
19{
20 Entry() = delete;
21
25 explicit Entry(clock_type::time_point const now)
26 : refcount(0)
27 , local_balance(now)
30 , whenExpires()
31 {
32 }
33
35 to_string() const
36 {
38 }
39
45 bool
47 {
48 return key->kind == kindUnlimited;
49 }
50
51 // Balance including remote contributions
52 int
54 {
55 return local_balance.value(now) + remote_balance;
56 }
57
58 // Add a charge and return normalized balance
59 // including contributions from imports.
60 int
61 add(int charge, clock_type::time_point const now)
62 {
63 return local_balance.add(charge, now) + remote_balance;
64 }
65
66 // The public key of the peer
68
69 // Back pointer to the map key (bit of a hack here)
70 Key const* key;
71
72 // Number of Consumer references
74
75 // Exponentially decaying balance of resource consumption
77
78 // Normalized balance contribution from imports
80
81 // Time of the last warning
83
84 // For inactive entries, time after which this entry will be erased
86};
87
89operator<<(std::ostream& os, Entry const& v)
90{
91 os << v.to_string();
92 return os;
93}
94
95} // namespace Resource
96} // namespace ripple
97
98#endif
Intrusive doubly linked list.
Definition List.h:260
Sampling function using exponential decay to provide a continuous value.
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition Charge.cpp:37
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::string getFingerprint(beast::IP::Endpoint const &address, std::optional< PublicKey > const &publicKey=std::nullopt, std::optional< std::string > const &id=std::nullopt)
Definition PublicKey.h:250
std::string to_string() const
Definition Entry.h:35
Key const * key
Definition Entry.h:70
Entry(clock_type::time_point const now)
Definition Entry.h:25
std::optional< PublicKey > publicKey
Definition Entry.h:67
bool isUnlimited() const
Returns true if this connection should have no resource limits applied–it is still possible for certa...
Definition Entry.h:46
int add(int charge, clock_type::time_point const now)
Definition Entry.h:61
int balance(clock_type::time_point const now)
Definition Entry.h:53
clock_type::time_point whenExpires
Definition Entry.h:85
clock_type::time_point lastWarningTime
Definition Entry.h:82
DecayingSample< decayWindowSeconds, clock_type > local_balance
Definition Entry.h:76
beast::IP::Endpoint address
Definition Key.h:15