rippled
Loading...
Searching...
No Matches
xrpld/overlay/Peer.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_OVERLAY_PEER_H_INCLUDED
21#define RIPPLE_OVERLAY_PEER_H_INCLUDED
22
23#include <xrpld/overlay/Message.h>
24
25#include <xrpl/basics/base_uint.h>
26#include <xrpl/beast/net/IPEndpoint.h>
27#include <xrpl/json/json_value.h>
28#include <xrpl/protocol/PublicKey.h>
29
30namespace ripple {
31
32namespace Resource {
33class Charge;
34}
35
41
43class Peer
44{
45public:
47
54
55 virtual ~Peer() = default;
56
57 //
58 // Network
59 //
60
61 virtual void
63
65 getRemoteAddress() const = 0;
66
68 virtual void
70
72 virtual void
73 addTxQueue(uint256 const&) = 0;
74
76 virtual void
78
80 virtual void
81 charge(Resource::Charge const& fee, std::string const& context) = 0;
82
83 //
84 // Identity
85 //
86
87 virtual id_t
88 id() const = 0;
89
91 virtual bool
92 cluster() const = 0;
93
94 virtual bool
95 isHighLatency() const = 0;
96
97 virtual int
98 getScore(bool) const = 0;
99
100 virtual PublicKey const&
101 getNodePublic() const = 0;
102
103 virtual Json::Value
104 json() = 0;
105
106 virtual bool
108
111
112 virtual void
114
115 virtual std::string const&
116 fingerprint() const = 0;
117 //
118 // Ledger
119 //
120
121 virtual uint256 const&
123 virtual bool
124 hasLedger(uint256 const& hash, std::uint32_t seq) const = 0;
125 virtual void
126 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const = 0;
127 virtual bool
128 hasTxSet(uint256 const& hash) const = 0;
129 virtual void
131 virtual bool
133
134 virtual bool
136
137 virtual bool
139};
140
141} // namespace ripple
142
143#endif
Represents a JSON value.
Definition json_value.h:149
A version-independent IP address and port combination.
Definition IPEndpoint.h:38
Represents a peer connection in the overlay.
virtual bool isHighLatency() const =0
virtual bool txReduceRelayEnabled() const =0
virtual ~Peer()=default
virtual bool supportsFeature(ProtocolFeature f) const =0
virtual int getScore(bool) const =0
virtual std::string const & fingerprint() const =0
virtual beast::IP::Endpoint getRemoteAddress() const =0
virtual Json::Value json()=0
virtual void send(std::shared_ptr< Message > const &m)=0
virtual bool compressionEnabled() const =0
virtual void cycleStatus()=0
virtual std::optional< std::size_t > publisherListSequence(PublicKey const &) const =0
virtual bool hasLedger(uint256 const &hash, std::uint32_t seq) const =0
virtual bool cluster() const =0
Returns true if this connection is a member of the cluster.
virtual void addTxQueue(uint256 const &)=0
Aggregate transaction's hash.
virtual bool hasRange(std::uint32_t uMin, std::uint32_t uMax)=0
virtual void sendTxQueue()=0
Send aggregated transactions' hashes.
virtual PublicKey const & getNodePublic() const =0
virtual void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const =0
virtual void removeTxQueue(uint256 const &)=0
Remove hash from the transactions' hashes queue.
virtual uint256 const & getClosedLedgerHash() const =0
virtual void setPublisherListSequence(PublicKey const &, std::size_t const)=0
virtual bool hasTxSet(uint256 const &hash) const =0
virtual void charge(Resource::Charge const &fee, std::string const &context)=0
Adjust this peer's load balance based on the type of load imposed.
virtual id_t id() const =0
A public key.
Definition PublicKey.h:62
A consumption charge.
Definition Charge.h:30
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25