rippled
Loading...
Searching...
No Matches
Key.h
1#ifndef XRPL_RESOURCE_KEY_H_INCLUDED
2#define XRPL_RESOURCE_KEY_H_INCLUDED
3
4#include <xrpl/beast/net/IPEndpoint.h>
5#include <xrpl/beast/utility/instrumentation.h>
6#include <xrpl/resource/detail/Kind.h>
7
8namespace ripple {
9namespace Resource {
10
11// The consumer key
12struct Key
13{
16
17 Key() = delete;
18
19 Key(Kind k, beast::IP::Endpoint const& addr) : kind(k), address(addr)
20 {
21 }
22
23 struct hasher
24 {
26 operator()(Key const& v) const
27 {
28 return m_addr_hash(v.address);
29 }
30
31 private:
33 };
34
35 struct key_equal
36 {
37 key_equal() = default;
38
39 bool
40 operator()(Key const& lhs, Key const& rhs) const
41 {
42 return lhs.kind == rhs.kind && lhs.address == rhs.address;
43 }
44
45 private:
46 };
47};
48
49} // namespace Resource
50} // namespace ripple
51
52#endif
A version-independent IP address and port combination.
Definition IPEndpoint.h:19
Kind
Kind of consumer.
Definition Kind.h:15
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::size_t operator()(Key const &v) const
Definition Key.h:26
beast::uhash m_addr_hash
Definition Key.h:32
bool operator()(Key const &lhs, Key const &rhs) const
Definition Key.h:40
beast::IP::Endpoint address
Definition Key.h:15
Key(Kind k, beast::IP::Endpoint const &addr)
Definition Key.h:19