rippled
Loading...
Searching...
No Matches
Key.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_RESOURCE_KEY_H_INCLUDED
21#define RIPPLE_RESOURCE_KEY_H_INCLUDED
22
23#include <xrpl/beast/net/IPEndpoint.h>
24#include <xrpl/beast/utility/instrumentation.h>
25#include <xrpl/resource/detail/Kind.h>
26
27namespace ripple {
28namespace Resource {
29
30// The consumer key
31struct Key
32{
35
36 Key() = delete;
37
38 Key(Kind k, beast::IP::Endpoint const& addr) : kind(k), address(addr)
39 {
40 }
41
42 struct hasher
43 {
45 operator()(Key const& v) const
46 {
47 return m_addr_hash(v.address);
48 }
49
50 private:
52 };
53
54 struct key_equal
55 {
56 key_equal() = default;
57
58 bool
59 operator()(Key const& lhs, Key const& rhs) const
60 {
61 return lhs.kind == rhs.kind && lhs.address == rhs.address;
62 }
63
64 private:
65 };
66};
67
68} // namespace Resource
69} // namespace ripple
70
71#endif
A version-independent IP address and port combination.
Definition IPEndpoint.h:38
Kind
Kind of consumer.
Definition Kind.h:34
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
std::size_t operator()(Key const &v) const
Definition Key.h:45
beast::uhash m_addr_hash
Definition Key.h:51
bool operator()(Key const &lhs, Key const &rhs) const
Definition Key.h:59
beast::IP::Endpoint address
Definition Key.h:34
Key(Kind k, beast::IP::Endpoint const &addr)
Definition Key.h:38