rippled
peerfinder/Slot.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_PEERFINDER_SLOT_H_INCLUDED
21 #define RIPPLE_PEERFINDER_SLOT_H_INCLUDED
22 
23 #include <ripple/beast/net/IPEndpoint.h>
24 #include <ripple/protocol/PublicKey.h>
25 #include <memory>
26 #include <optional>
27 
28 namespace ripple {
29 namespace PeerFinder {
30 
32 class Slot
33 {
34 public:
36 
38 
39  virtual ~Slot() = 0;
40 
42  virtual bool
43  inbound() const = 0;
44 
49  virtual bool
50  fixed() const = 0;
51 
56  virtual bool
57  reserved() const = 0;
58 
60  virtual State
61  state() const = 0;
62 
64  virtual beast::IP::Endpoint const&
65  remote_endpoint() const = 0;
66 
69  local_endpoint() const = 0;
70 
72  listening_port() const = 0;
73 
77  virtual std::optional<PublicKey> const&
78  public_key() const = 0;
79 };
80 
81 } // namespace PeerFinder
82 } // namespace ripple
83 
84 #endif
ripple::PeerFinder::Slot::state
virtual State state() const =0
Returns the state of the connection.
std::shared_ptr
STL class.
ripple::PeerFinder::Slot::accept
@ accept
Definition: peerfinder/Slot.h:37
ripple::PeerFinder::Slot::fixed
virtual bool fixed() const =0
Returns true if this is a fixed connection.
ripple::PeerFinder::Slot::active
@ active
Definition: peerfinder/Slot.h:37
ripple::PeerFinder::Slot::reserved
virtual bool reserved() const =0
Returns true if this is a reserved connection.
ripple::PeerFinder::Slot::remote_endpoint
virtual beast::IP::Endpoint const & remote_endpoint() const =0
The remote endpoint of socket.
ripple::PeerFinder::Slot::connected
@ connected
Definition: peerfinder/Slot.h:37
ripple::PeerFinder::Slot::closing
@ closing
Definition: peerfinder/Slot.h:37
ripple::PeerFinder::Slot::State
State
Definition: peerfinder/Slot.h:37
memory
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
optional
ripple::PeerFinder::Slot::public_key
virtual std::optional< PublicKey > const & public_key() const =0
The peer's public key, when known.
ripple::PeerFinder::Slot::inbound
virtual bool inbound() const =0
Returns true if this is an inbound connection.
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
ripple::PeerFinder::Slot::local_endpoint
virtual std::optional< beast::IP::Endpoint > const & local_endpoint() const =0
The local endpoint of the socket, when known.
ripple::PeerFinder::Slot::~Slot
virtual ~Slot()=0
ripple::PeerFinder::Slot::listening_port
virtual std::optional< std::uint16_t > listening_port() const =0
ripple::PeerFinder::Slot::connect
@ connect
Definition: peerfinder/Slot.h:37
ripple::PeerFinder::Slot
Properties and state associated with a peer to peer overlay connection.
Definition: peerfinder/Slot.h:32