rippled
PeerImp.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_PEERIMP_H_INCLUDED
21 #define RIPPLE_OVERLAY_PEERIMP_H_INCLUDED
22 
23 #include <ripple/app/consensus/RCLCxPeerPos.h>
24 #include <ripple/basics/Log.h>
25 #include <ripple/basics/RangeSet.h>
26 #include <ripple/beast/utility/WrappedSink.h>
27 #include <ripple/overlay/Squelch.h>
28 #include <ripple/overlay/impl/OverlayImpl.h>
29 #include <ripple/overlay/impl/ProtocolMessage.h>
30 #include <ripple/overlay/impl/ProtocolVersion.h>
31 #include <ripple/peerfinder/PeerfinderManager.h>
32 #include <ripple/protocol/Protocol.h>
33 #include <ripple/protocol/STTx.h>
34 #include <ripple/protocol/STValidation.h>
35 #include <ripple/resource/Fees.h>
36 
37 #include <boost/circular_buffer.hpp>
38 #include <boost/endian/conversion.hpp>
39 #include <boost/optional.hpp>
40 #include <boost/thread/shared_mutex.hpp>
41 #include <cstdint>
42 #include <queue>
43 
44 namespace ripple {
45 
46 class PeerImp : public Peer,
47  public std::enable_shared_from_this<PeerImp>,
48  public OverlayImpl::Child
49 {
50 public:
52  enum class Tracking { diverged, unknown, converged };
53 
54  struct ShardInfo
55  {
58  };
59 
60 private:
62  using error_code = boost::system::error_code;
63  using socket_type = boost::asio::ip::tcp::socket;
64  using middle_type = boost::beast::tcp_stream;
65  using stream_type = boost::beast::ssl_stream<middle_type>;
66  using address_type = boost::asio::ip::address;
67  using endpoint_type = boost::asio::ip::tcp::endpoint;
68  using waitable_timer =
69  boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
71 
73  id_t const id_;
81  boost::asio::strand<boost::asio::executor> strand_;
83 
84  // Updated at each stage of the connection process to reflect
85  // the current conditions as closely as possible.
87 
88  // These are up here to prevent warnings about order of initializations
89  //
91  bool const inbound_;
92 
93  // Protocol version to use for this link
95 
97  clock_type::time_point trackingTime_;
98  bool detaching_ = false;
99  // Node public key of peer.
102  boost::shared_mutex mutable nameMutex_;
103 
104  // The indices of the smallest and largest ledgers this peer has available
105  //
110 
111  boost::circular_buffer<uint256> recentLedgers_{128};
112  boost::circular_buffer<uint256> recentTxSets_{128};
113 
114  boost::optional<std::chrono::milliseconds> latency_;
115  boost::optional<std::uint32_t> lastPingSeq_;
116  clock_type::time_point lastPingTime_;
117  clock_type::time_point const creationTime_;
118 
120 
121  // Notes on thread locking:
122  //
123  // During an audit it was noted that some member variables that looked
124  // like they need thread protection were not receiving it. And, indeed,
125  // that was correct. But the multi-phase initialization of PeerImp
126  // makes such an audit difficult. A further audit suggests that the
127  // locking is now protecting variables that don't need it. We're
128  // leaving that locking in place (for now) as a form of future proofing.
129  //
130  // Here are the variables that appear to need locking currently:
131  //
132  // o closedLedgerHash_
133  // o previousLedgerHash_
134  // o minLedger_
135  // o maxLedger_
136  // o recentLedgers_
137  // o recentTxSets_
138  // o trackingTime_
139  // o latency_
140  //
141  // The following variables are being protected preemptively:
142  //
143  // o name_
144  // o last_status_
145  //
146  // June 2019
147 
149  protocol::TMStatusChange last_status_;
153  boost::beast::multi_buffer read_buffer_;
156  boost::beast::http::fields const& headers_;
158  bool gracefulClose_ = false;
159  int large_sendq_ = 0;
161  // The highest sequence of each PublisherList that has
162  // been sent to or received from this peer.
164 
167 
169 
170  friend class OverlayImpl;
171 
172  class Metrics
173  {
174  public:
175  Metrics() = default;
176  Metrics(Metrics const&) = delete;
177  Metrics&
178  operator=(Metrics const&) = delete;
179  Metrics(Metrics&&) = delete;
180  Metrics&
181  operator=(Metrics&&) = delete;
182 
183  void
184  add_message(std::uint64_t bytes);
186  average_bytes() const;
188  total_bytes() const;
189 
190  private:
191  boost::shared_mutex mutable mutex_;
192  boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
193  clock_type::time_point intervalStart_{clock_type::now()};
197  };
198 
199  struct
200  {
203  } metrics_;
204 
205 public:
206  PeerImp(PeerImp const&) = delete;
207  PeerImp&
208  operator=(PeerImp const&) = delete;
209 
211  PeerImp(
212  Application& app,
213  id_t id,
215  http_request_type&& request,
216  PublicKey const& publicKey,
217  ProtocolVersion protocol,
218  Resource::Consumer consumer,
219  std::unique_ptr<stream_type>&& stream_ptr,
220  OverlayImpl& overlay);
221 
223  // VFALCO legacyPublicKey should be implied by the Slot
224  template <class Buffers>
225  PeerImp(
226  Application& app,
227  std::unique_ptr<stream_type>&& stream_ptr,
228  Buffers const& buffers,
230  http_response_type&& response,
231  Resource::Consumer usage,
232  PublicKey const& publicKey,
233  ProtocolVersion protocol,
234  id_t id,
235  OverlayImpl& overlay);
236 
237  virtual ~PeerImp();
238 
239  beast::Journal const&
240  pjournal() const
241  {
242  return p_journal_;
243  }
244 
247  {
248  return slot_;
249  }
250 
251  // Work-around for calling shared_from_this in constructors
252  void
253  run();
254 
255  // Called when Overlay gets a stop request.
256  void
257  stop() override;
258 
259  //
260  // Network
261  //
262 
263  void
264  send(std::shared_ptr<Message> const& m) override;
265 
267  template <
268  class FwdIt,
269  class = typename std::enable_if_t<std::is_same<
271  PeerFinder::Endpoint>::value>>
272  void
273  sendEndpoints(FwdIt first, FwdIt last);
274 
276  getRemoteAddress() const override
277  {
278  return remote_address_;
279  }
280 
281  void
282  charge(Resource::Charge const& fee) override;
283 
284  //
285  // Identity
286  //
287 
288  Peer::id_t
289  id() const override
290  {
291  return id_;
292  }
293 
295  bool
296  crawl() const;
297 
298  bool
299  cluster() const override;
300 
304  void
305  checkTracking(std::uint32_t validationSeq);
306 
307  void
309 
310  PublicKey const&
311  getNodePublic() const override
312  {
313  return publicKey_;
314  }
315 
318  getVersion() const;
319 
320  // Return the connection elapsed time.
321  clock_type::duration
322  uptime() const
323  {
324  return clock_type::now() - creationTime_;
325  }
326 
328  json() override;
329 
330  bool
331  supportsFeature(ProtocolFeature f) const override;
332 
333  boost::optional<std::size_t>
334  publisherListSequence(PublicKey const& pubKey) const override
335  {
337 
338  auto iter = publisherListSequences_.find(pubKey);
339  if (iter != publisherListSequences_.end())
340  return iter->second;
341  return {};
342  }
343 
344  void
346  override
347  {
349 
350  publisherListSequences_[pubKey] = seq;
351  }
352 
353  //
354  // Ledger
355  //
356 
357  uint256 const&
358  getClosedLedgerHash() const override
359  {
360  return closedLedgerHash_;
361  }
362 
363  bool
364  hasLedger(uint256 const& hash, std::uint32_t seq) const override;
365 
366  void
367  ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
368 
369  bool
370  hasShard(std::uint32_t shardIndex) const override;
371 
372  bool
373  hasTxSet(uint256 const& hash) const override;
374 
375  void
376  cycleStatus() override;
377 
378  bool
379  hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
380 
381  // Called to determine our priority for querying
382  int
383  getScore(bool haveItem) const override;
384 
385  bool
386  isHighLatency() const override;
387 
388  void
389  fail(std::string const& reason);
390 
392  boost::optional<RangeSet<std::uint32_t>>
393  getShardIndexes() const;
394 
396  boost::optional<hash_map<PublicKey, ShardInfo>>
397  getPeerShardInfo() const;
398 
399  bool
400  compressionEnabled() const override
401  {
403  }
404 
405 private:
406  void
407  close();
408 
409  void
410  fail(std::string const& name, error_code ec);
411 
412  void
413  gracefulClose();
414 
415  void
416  setTimer();
417 
418  void
419  cancelTimer();
420 
421  static std::string
422  makePrefix(id_t id);
423 
424  // Called when the timer wait completes
425  void
426  onTimer(boost::system::error_code const& ec);
427 
428  // Called when SSL shutdown completes
429  void
431 
432  void
433  doAccept();
434 
436  name() const;
437 
439  domain() const;
440 
442  networkID() const;
443 
444  //
445  // protocol message loop
446  //
447 
448  // Starts the protocol message loop
449  void
450  doProtocolStart();
451 
452  // Called when protocol message bytes are received
453  void
454  onReadMessage(error_code ec, std::size_t bytes_transferred);
455 
456  // Called when protocol messages bytes are sent
457  void
458  onWriteMessage(error_code ec, std::size_t bytes_transferred);
459 
460 public:
461  //--------------------------------------------------------------------------
462  //
463  // ProtocolStream
464  //
465  //--------------------------------------------------------------------------
466 
467  void
469 
470  void
472  std::uint16_t type,
474  std::size_t size);
475 
476  void
477  onMessageEnd(
478  std::uint16_t type,
480 
481  void
483  void
485  void
487  void
489  void
491  void
493  void
495  void
497  void
499  void
501  void
503  void
505  void
507  void
509  void
511  void
513  void
515  void
517 
518 private:
519  //--------------------------------------------------------------------------
520  // lockedRecentLock is passed as a reminder to callers that recentLock_
521  // must be locked.
522  void
523  addLedger(
524  uint256 const& hash,
525  std::lock_guard<std::mutex> const& lockedRecentLock);
526 
527  void
529 
530  void
532  int flags,
533  bool checkSignature,
534  std::shared_ptr<STTx const> const& stx);
535 
536  void
537  checkPropose(
538  Job& job,
540  RCLCxPeerPos peerPos);
541 
542  void
546 
547  void
549 };
550 
551 //------------------------------------------------------------------------------
552 
553 template <class Buffers>
555  Application& app,
556  std::unique_ptr<stream_type>&& stream_ptr,
557  Buffers const& buffers,
559  http_response_type&& response,
560  Resource::Consumer usage,
561  PublicKey const& publicKey,
562  ProtocolVersion protocol,
563  id_t id,
564  OverlayImpl& overlay)
565  : Child(overlay)
566  , app_(app)
567  , id_(id)
568  , sink_(app_.journal("Peer"), makePrefix(id))
569  , p_sink_(app_.journal("Protocol"), makePrefix(id))
570  , journal_(sink_)
571  , p_journal_(p_sink_)
572  , stream_ptr_(std::move(stream_ptr))
573  , socket_(stream_ptr_->next_layer().socket())
574  , stream_(*stream_ptr_)
575  , strand_(socket_.get_executor())
576  , timer_(waitable_timer{socket_.get_executor()})
577  , remote_address_(slot->remote_endpoint())
578  , overlay_(overlay)
579  , inbound_(false)
580  , protocol_(protocol)
581  , tracking_(Tracking::unknown)
582  , trackingTime_(clock_type::now())
583  , publicKey_(publicKey)
584  , lastPingTime_(clock_type::now())
585  , creationTime_(clock_type::now())
586  , usage_(usage)
587  , fee_(Resource::feeLightPeer)
588  , slot_(std::move(slot))
589  , response_(std::move(response))
590  , headers_(response_)
591  , compressionEnabled_(
592  headers_["X-Offer-Compression"] == "lz4" && app_.config().COMPRESSION
593  ? Compressed::On
594  : Compressed::Off)
595 {
596  read_buffer_.commit(boost::asio::buffer_copy(
597  read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
598 }
599 
600 template <class FwdIt, class>
601 void
602 PeerImp::sendEndpoints(FwdIt first, FwdIt last)
603 {
604  protocol::TMEndpoints tm;
605 
606  while (first != last)
607  {
608  auto& tme2(*tm.add_endpoints_v2());
609  tme2.set_endpoint(first->address.to_string());
610  tme2.set_hops(first->hops);
611  first++;
612  }
613  tm.set_version(2);
614 
615  send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
616 }
617 
618 } // namespace ripple
619 
620 #endif
ripple::PeerImp::ledgerRange
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition: PeerImp.cpp:460
ripple::PeerImp::uptime
clock_type::duration uptime() const
Definition: PeerImp.h:322
ripple::Application
Definition: Application.h:97
ripple::PeerImp::Metrics::Metrics
Metrics()=default
ripple::PeerImp::inbound_
const bool inbound_
Definition: PeerImp.h:91
std::is_same
ripple::PeerImp::recentLock_
std::mutex recentLock_
Definition: PeerImp.h:148
std::chrono::steady_clock
ripple::RCLCxPeerPos
A peer's signed, proposed position for use in RCLConsensus.
Definition: RCLCxPeerPos.h:42
ripple::compression::Compressed::On
@ On
ripple::PeerImp::stream_ptr_
std::unique_ptr< stream_type > stream_ptr_
Definition: PeerImp.h:78
ripple::PeerImp::onMessageBegin
void onMessageBegin(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m, std::size_t size)
Definition: PeerImp.cpp:967
ripple::PeerImp::socket_
socket_type & socket_
Definition: PeerImp.h:79
ripple::PeerImp::trackingTime_
clock_type::time_point trackingTime_
Definition: PeerImp.h:97
std::string
STL class.
std::shared_ptr
STL class.
ripple::PeerImp::onMessage
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition: PeerImp.cpp:989
ripple::PeerImp::hasTxSet
bool hasTxSet(uint256 const &hash) const override
Definition: PeerImp.cpp:479
ripple::PeerImp::strand_
boost::asio::strand< boost::asio::executor > strand_
Definition: PeerImp.h:81
ripple::PeerImp::recentLedgers_
boost::circular_buffer< uint256 > recentLedgers_
Definition: PeerImp.h:111
ripple::PeerImp::publisherListSequence
boost::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition: PeerImp.h:334
ripple::PeerImp::request_
http_request_type request_
Definition: PeerImp.h:154
ripple::PeerImp::~PeerImp
virtual ~PeerImp()
Definition: PeerImp.cpp:109
ripple::PeerImp::getShardIndexes
boost::optional< RangeSet< std::uint32_t > > getShardIndexes() const
Return a range set of known shard indexes from this peer.
Definition: PeerImp.cpp:561
std::pair
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handoff.h:31
ripple::PeerImp::doAccept
void doAccept()
Definition: PeerImp.cpp:713
ripple::Peer::id_t
std::uint32_t id_t
Uniquely identifies a peer.
Definition: ripple/overlay/Peer.h:53
ripple::PeerImp::doProtocolStart
void doProtocolStart()
Definition: PeerImp.cpp:813
ripple::PeerImp::getScore
int getScore(bool haveItem) const override
Definition: PeerImp.cpp:2864
ripple::PeerImp::recentTxSets_
boost::circular_buffer< uint256 > recentTxSets_
Definition: PeerImp.h:112
ripple::PeerImp::checkValidation
void checkValidation(std::shared_ptr< STValidation > const &val, std::shared_ptr< protocol::TMValidation > const &packet)
Definition: PeerImp.cpp:2437
ripple::PeerImp::checkPropose
void checkPropose(Job &job, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition: PeerImp.cpp:2391
ripple::PeerImp::id
Peer::id_t id() const override
Definition: PeerImp.h:289
ripple::PeerImp::setTimer
void setTimer()
Definition: PeerImp.cpp:601
ripple::PeerImp::getVersion
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition: PeerImp.cpp:304
ripple::PeerImp::slot
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition: PeerImp.h:246
ripple::PeerImp::Metrics::accumBytes_
std::uint64_t accumBytes_
Definition: PeerImp.h:195
std::lock_guard
STL class.
ripple::PeerImp::close
void close()
Definition: PeerImp.cpp:507
ripple::PeerImp::charge
void charge(Resource::Charge const &fee) override
Adjust this peer's load balance based on the type of load imposed.
Definition: PeerImp.cpp:275
ripple::PeerImp::sink_
beast::WrappedSink sink_
Definition: PeerImp.h:74
ripple::PeerImp::onMessageUnknown
void onMessageUnknown(std::uint16_t type)
Definition: PeerImp.cpp:961
ripple::PeerImp::Metrics::average_bytes
std::uint64_t average_bytes() const
Definition: PeerImp.cpp:2935
ripple::PeerImp::getLedger
void getLedger(std::shared_ptr< protocol::TMGetLedger > const &packet)
Definition: PeerImp.cpp:2535
ripple::PeerImp::squelch_
squelch::Squelch< UptimeClock > squelch_
Definition: PeerImp.h:119
ripple::PeerImp::ShardInfo::endpoint
beast::IP::Endpoint endpoint
Definition: PeerImp.h:56
ripple::PeerImp::journal_
const beast::Journal journal_
Definition: PeerImp.h:76
ripple::PeerImp::isHighLatency
bool isHighLatency() const override
Definition: PeerImp.cpp:2902
ripple::PeerImp::send
void send(std::shared_ptr< Message > const &m) override
Definition: PeerImp.cpp:220
ripple::ProtocolFeature
ProtocolFeature
Definition: ripple/overlay/Peer.h:38
ripple::PeerImp::onTimer
void onTimer(boost::system::error_code const &ec)
Definition: PeerImp.cpp:636
ripple::PeerImp::lastPingTime_
clock_type::time_point lastPingTime_
Definition: PeerImp.h:116
ripple::PeerImp::creationTime_
const clock_type::time_point creationTime_
Definition: PeerImp.h:117
ripple::PeerImp::doFetchPack
void doFetchPack(const std::shared_ptr< protocol::TMGetObjectByHash > &packet)
Definition: PeerImp.cpp:2283
queue
ripple::PeerImp
Definition: PeerImp.h:46
ripple::PeerImp::socket_type
boost::asio::ip::tcp::socket socket_type
Definition: PeerImp.h:63
ripple::PeerImp::previousLedgerHash_
uint256 previousLedgerHash_
Definition: PeerImp.h:109
ripple::PeerImp::Metrics::rollingAvgBytes_
std::uint64_t rollingAvgBytes_
Definition: PeerImp.h:196
ripple::PeerImp::name_
std::string name_
Definition: PeerImp.h:101
ripple::PeerImp::recv
Metrics recv
Definition: PeerImp.h:202
ripple::PeerImp::Metrics::intervalStart_
clock_type::time_point intervalStart_
Definition: PeerImp.h:193
ripple::PeerImp::publicKey_
const PublicKey publicKey_
Definition: PeerImp.h:100
ripple::PeerImp::read_buffer_
boost::beast::multi_buffer read_buffer_
Definition: PeerImp.h:153
ripple::PeerImp::error_code
boost::system::error_code error_code
Definition: PeerImp.h:62
ripple::PeerImp::remote_address_
const beast::IP::Endpoint remote_address_
Definition: PeerImp.h:86
ripple::PeerImp::networkID
std::optional< std::uint32_t > networkID() const
ripple::base_uint< 256 >
ripple::PeerImp::Metrics::totalBytes_
std::uint64_t totalBytes_
Definition: PeerImp.h:194
ripple::PeerImp::addLedger
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition: PeerImp.cpp:2267
ripple::http_response_type
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
Definition: Handoff.h:34
ripple::PeerImp::sent
Metrics sent
Definition: PeerImp.h:201
ripple::PeerImp::Metrics
Definition: PeerImp.h:172
ripple::PeerImp::gracefulClose
void gracefulClose()
Definition: PeerImp.cpp:580
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
std::enable_if_t
ripple::PeerImp::shardInfo_
hash_map< PublicKey, ShardInfo > shardInfo_
Definition: PeerImp.h:166
ripple::PeerImp::closedLedgerHash_
uint256 closedLedgerHash_
Definition: PeerImp.h:108
ripple::PeerImp::lastPingSeq_
boost::optional< std::uint32_t > lastPingSeq_
Definition: PeerImp.h:115
ripple::PeerImp::detaching_
bool detaching_
Definition: PeerImp.h:98
ripple::PeerImp::onMessageEnd
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition: PeerImp.cpp:980
std::iterator_traits
ripple::PeerImp::getNodePublic
PublicKey const & getNodePublic() const override
Definition: PeerImp.h:311
ripple::PeerImp::stream_
stream_type & stream_
Definition: PeerImp.h:80
ripple::PeerImp::onWriteMessage
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:907
ripple::PeerImp::hasRange
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition: PeerImp.cpp:497
ripple::PeerImp::cycleStatus
void cycleStatus() override
Definition: PeerImp.cpp:487
ripple::PeerImp::app_
Application & app_
Definition: PeerImp.h:72
ripple::PeerImp::crawl
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition: PeerImp.cpp:289
ripple::PeerImp::minLedger_
LedgerIndex minLedger_
Definition: PeerImp.h:106
std::enable_shared_from_this
ripple::compression::Compressed::Off
@ Off
ripple::compression::Compressed
Compressed
Definition: Compression.h:38
ripple::PeerImp::hasLedger
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition: PeerImp.cpp:443
ripple::PeerImp::Tracking::unknown
@ unknown
cstdint
ripple::PeerImp::address_type
boost::asio::ip::address address_type
Definition: PeerImp.h:66
ripple::Job
Definition: Job.h:82
ripple::PeerImp::headers_
boost::beast::http::fields const & headers_
Definition: PeerImp.h:156
ripple::PeerImp::publisherListSequences_
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition: PeerImp.h:163
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::PeerImp::metrics_
struct ripple::PeerImp::@13 metrics_
std::uint32_t
ripple::PeerImp::send_queue_
std::queue< std::shared_ptr< Message > > send_queue_
Definition: PeerImp.h:157
ripple::PeerImp::sendEndpoints
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition: PeerImp.h:602
ripple::PeerImp::Metrics::total_bytes
std::uint64_t total_bytes() const
Definition: PeerImp.cpp:2942
ripple::PeerImp::slot_
const std::shared_ptr< PeerFinder::Slot > slot_
Definition: PeerImp.h:152
std::atomic< Tracking >
ripple::PeerImp::Tracking
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition: PeerImp.h:52
ripple::PeerImp::load_event_
std::unique_ptr< LoadEvent > load_event_
Definition: PeerImp.h:160
ripple::PeerImp::protocol_
ProtocolVersion protocol_
Definition: PeerImp.h:94
ripple::PeerImp::p_sink_
beast::WrappedSink p_sink_
Definition: PeerImp.h:75
ripple::PeerImp::waitable_timer
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition: PeerImp.h:69
ripple::PeerImp::onShutdown
void onShutdown(error_code ec)
Definition: PeerImp.cpp:697
ripple::PeerImp::PeerImp
PeerImp(PeerImp const &)=delete
ripple::PeerImp::Metrics::add_message
void add_message(std::uint64_t bytes)
Definition: PeerImp.cpp:2909
ripple::PeerImp::name
std::string name() const
Definition: PeerImp.cpp:796
ripple::PeerImp::timer_
waitable_timer timer_
Definition: PeerImp.h:82
ripple::PeerImp::ShardInfo
Definition: PeerImp.h:54
ripple::PeerImp::Tracking::diverged
@ diverged
ripple::PeerImp::gracefulClose_
bool gracefulClose_
Definition: PeerImp.h:158
ripple::PeerImp::latency_
boost::optional< std::chrono::milliseconds > latency_
Definition: PeerImp.h:114
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::PeerImp::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: PeerImp.h:67
ripple::squelch::Squelch
Maintains squelching of relaying messages from validators.
Definition: Squelch.h:36
std
STL namespace.
ripple::PeerImp::hasShard
bool hasShard(std::uint32_t shardIndex) const override
Definition: PeerImp.cpp:469
ripple::Resource::Consumer
An endpoint that consumes resources.
Definition: Consumer.h:33
ripple::Resource::Charge
A consumption charge.
Definition: Charge.h:30
ripple::PeerImp::Metrics::rollingAvg_
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition: PeerImp.h:192
ripple::PeerImp::maxLedger_
LedgerIndex maxLedger_
Definition: PeerImp.h:107
ripple::PeerImp::run
void run()
Definition: PeerImp.cpp:132
ripple::PeerImp::checkTracking
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition: PeerImp.cpp:1796
ripple::PeerImp::large_sendq_
int large_sendq_
Definition: PeerImp.h:159
ripple::PeerImp::pjournal
beast::Journal const & pjournal() const
Definition: PeerImp.h:240
beast::WrappedSink
Wraps a Journal::Sink to prefix its output with a string.
Definition: WrappedSink.h:33
ripple::PeerImp::domain
std::string domain() const
Definition: PeerImp.cpp:803
ripple::Resource::feeLightPeer
const Charge feeLightPeer
ripple::PeerImp::last_status_
protocol::TMStatusChange last_status_
Definition: PeerImp.h:149
ripple::PeerImp::setPublisherListSequence
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition: PeerImp.h:345
ripple::PeerImp::supportsFeature
bool supportsFeature(ProtocolFeature f) const override
Definition: PeerImp.cpp:430
ripple::PeerImp::getClosedLedgerHash
uint256 const & getClosedLedgerHash() const override
Definition: PeerImp.h:358
std::optional< std::uint32_t >
std::mutex
STL class.
std::size_t
ripple::PeerImp::json
Json::Value json() override
Definition: PeerImp.cpp:312
ripple::PeerImp::compressionEnabled_
Compressed compressionEnabled_
Definition: PeerImp.h:168
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
ripple::PeerImp::makePrefix
static std::string makePrefix(id_t id)
Definition: PeerImp.cpp:628
ripple::PeerImp::usage_
Resource::Consumer usage_
Definition: PeerImp.h:150
ripple::RangeSet
boost::icl::interval_set< T, std::less, ClosedInterval< T > > RangeSet
A set of closed intervals over the domain T.
Definition: RangeSet.h:69
ripple::PeerImp::Metrics::mutex_
boost::shared_mutex mutex_
Definition: PeerImp.h:191
ripple::PeerImp::checkTransaction
void checkTransaction(int flags, bool checkSignature, std::shared_ptr< STTx const > const &stx)
Definition: PeerImp.cpp:2317
ripple::PeerImp::middle_type
boost::beast::tcp_stream middle_type
Definition: PeerImp.h:64
ripple::OverlayImpl
Definition: OverlayImpl.h:57
ripple::PeerImp::getPeerShardInfo
boost::optional< hash_map< PublicKey, ShardInfo > > getPeerShardInfo() const
Return any known shard info from this peer and its sub peers.
Definition: PeerImp.cpp:571
ripple::PeerFinder::Endpoint
Describes a connectible peer address along with some metadata.
Definition: PeerfinderManager.h:114
ripple::PeerImp::response_
http_response_type response_
Definition: PeerImp.h:155
ripple::PeerImp::shardInfoMutex_
std::mutex shardInfoMutex_
Definition: PeerImp.h:165
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:60
ripple::PeerImp::overlay_
OverlayImpl & overlay_
Definition: PeerImp.h:90
ripple::PeerImp::compressionEnabled
bool compressionEnabled() const override
Definition: PeerImp.h:400
ripple::PeerImp::getRemoteAddress
beast::IP::Endpoint getRemoteAddress() const override
Definition: PeerImp.h:276
std::unique_ptr< stream_type >
ripple::PeerImp::stream_type
boost::beast::ssl_stream< middle_type > stream_type
Definition: PeerImp.h:65
ripple::PeerImp::tracking_
std::atomic< Tracking > tracking_
Definition: PeerImp.h:96
ripple::PeerImp::nameMutex_
boost::shared_mutex nameMutex_
Definition: PeerImp.h:102
ripple::PeerImp::cancelTimer
void cancelTimer()
Definition: PeerImp.cpp:619
std::unordered_map
STL class.
ripple::PeerImp::fee_
Resource::Charge fee_
Definition: PeerImp.h:151
ripple::PeerImp::stop
void stop() override
Definition: PeerImp.cpp:194
ripple::PeerImp::Tracking::converged
@ converged
ripple::PeerImp::id_
const id_t id_
Definition: PeerImp.h:73
ripple::PeerImp::fail
void fail(std::string const &reason)
Definition: PeerImp.cpp:529
ripple::PeerImp::cluster
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition: PeerImp.cpp:298
ripple::PeerImp::operator=
PeerImp & operator=(PeerImp const &)=delete
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::PeerImp::p_journal_
const beast::Journal p_journal_
Definition: PeerImp.h:77
ripple::Peer
Represents a peer connection in the overlay.
Definition: ripple/overlay/Peer.h:43
ripple::PeerImp::ShardInfo::shardIndexes
RangeSet< std::uint32_t > shardIndexes
Definition: PeerImp.h:57
ripple::PeerImp::Metrics::operator=
Metrics & operator=(Metrics const &)=delete
ripple::PeerImp::onReadMessage
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:851
std::chrono::steady_clock::now
T now(T... args)