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