rippled
Loading...
Searching...
No Matches
Consumer.h
1#ifndef XRPL_RESOURCE_CONSUMER_H_INCLUDED
2#define XRPL_RESOURCE_CONSUMER_H_INCLUDED
3
4#include <xrpl/basics/Log.h>
5#include <xrpl/protocol/PublicKey.h>
6#include <xrpl/resource/Charge.h>
7#include <xrpl/resource/Disposition.h>
8
9namespace ripple {
10namespace Resource {
11
12struct Entry;
13class Logic;
14
17{
18private:
19 friend class Logic;
20 Consumer(Logic& logic, Entry& entry);
21
22public:
23 Consumer();
24 ~Consumer();
25 Consumer(Consumer const& other);
27 operator=(Consumer const& other);
28
31 to_string() const;
32
34 bool
35 isUnlimited() const;
36
40 void
41 elevate(std::string const& name);
42
48 disposition() const;
49
52 charge(Charge const& fee, std::string const& context = {});
53
57 bool
58 warn();
59
61 bool
62 disconnect(beast::Journal const& j);
63
65 int
66 balance();
67
68 // Private: Retrieve the entry associated with the consumer
69 Entry&
70 entry();
71
72 void
73 setPublicKey(PublicKey const& publicKey);
74
75private:
78};
79
81operator<<(std::ostream& os, Consumer const& v);
82
83} // namespace Resource
84} // namespace ripple
85
86#endif
A generic endpoint for log messages.
Definition Journal.h:41
A public key.
Definition PublicKey.h:43
A consumption charge.
Definition Charge.h:11
An endpoint that consumes resources.
Definition Consumer.h:17
bool warn()
Returns true if the consumer should be warned.
Definition Consumer.cpp:98
Consumer & operator=(Consumer const &other)
Definition Consumer.cpp:42
int balance()
Returns the credit balance representing consumption.
Definition Consumer.cpp:118
std::string to_string() const
Return a human readable string uniquely identifying this consumer.
Definition Consumer.cpp:59
bool disconnect(beast::Journal const &j)
Returns true if the consumer should be disconnected.
Definition Consumer.cpp:105
Disposition charge(Charge const &fee, std::string const &context={})
Apply a load charge to the consumer.
Definition Consumer.cpp:87
void setPublicKey(PublicKey const &publicKey)
Definition Consumer.cpp:133
bool isUnlimited() const
Returns true if this is a privileged endpoint.
Definition Consumer.cpp:68
Disposition disposition() const
Returns the current disposition of this consumer.
Definition Consumer.cpp:77
void elevate(std::string const &name)
Raise the Consumer's privilege level to a Named endpoint.
std::ostream & operator<<(std::ostream &os, Charge const &v)
Definition Charge.cpp:37
Disposition
The disposition of a consumer after applying a load charge.
Definition Disposition.h:8
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6