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 struct ValidatorBlobInfo;
47 
48 class PeerImp : public Peer,
49  public std::enable_shared_from_this<PeerImp>,
50  public OverlayImpl::Child
51 {
52 public:
54  enum class Tracking { diverged, unknown, converged };
55 
56  struct ShardInfo
57  {
60  };
61 
62 private:
64  using error_code = boost::system::error_code;
65  using socket_type = boost::asio::ip::tcp::socket;
66  using middle_type = boost::beast::tcp_stream;
67  using stream_type = boost::beast::ssl_stream<middle_type>;
68  using address_type = boost::asio::ip::address;
69  using endpoint_type = boost::asio::ip::tcp::endpoint;
70  using waitable_timer =
71  boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
73 
75  id_t const id_;
83  boost::asio::strand<boost::asio::executor> strand_;
85 
86  // Updated at each stage of the connection process to reflect
87  // the current conditions as closely as possible.
89 
90  // These are up here to prevent warnings about order of initializations
91  //
93  bool const inbound_;
94 
95  // Protocol version to use for this link
97 
99  clock_type::time_point trackingTime_;
100  bool detaching_ = false;
101  // Node public key of peer.
104  boost::shared_mutex mutable nameMutex_;
105 
106  // The indices of the smallest and largest ledgers this peer has available
107  //
112 
113  boost::circular_buffer<uint256> recentLedgers_{128};
114  boost::circular_buffer<uint256> recentTxSets_{128};
115 
116  boost::optional<std::chrono::milliseconds> latency_;
117  boost::optional<std::uint32_t> lastPingSeq_;
118  clock_type::time_point lastPingTime_;
119  clock_type::time_point const creationTime_;
120 
122  inline static std::atomic_bool reduceRelayReady_{false};
123 
124  // Notes on thread locking:
125  //
126  // During an audit it was noted that some member variables that looked
127  // like they need thread protection were not receiving it. And, indeed,
128  // that was correct. But the multi-phase initialization of PeerImp
129  // makes such an audit difficult. A further audit suggests that the
130  // locking is now protecting variables that don't need it. We're
131  // leaving that locking in place (for now) as a form of future proofing.
132  //
133  // Here are the variables that appear to need locking currently:
134  //
135  // o closedLedgerHash_
136  // o previousLedgerHash_
137  // o minLedger_
138  // o maxLedger_
139  // o recentLedgers_
140  // o recentTxSets_
141  // o trackingTime_
142  // o latency_
143  //
144  // The following variables are being protected preemptively:
145  //
146  // o name_
147  // o last_status_
148  //
149  // June 2019
150 
152  protocol::TMStatusChange last_status_;
156  boost::beast::multi_buffer read_buffer_;
159  boost::beast::http::fields const& headers_;
161  bool gracefulClose_ = false;
162  int large_sendq_ = 0;
164  // The highest sequence of each PublisherList that has
165  // been sent to or received from this peer.
167 
170 
172 
173  // true if validation/proposal reduce-relay feature is enabled
174  // on the peer.
175  bool vpReduceRelayEnabled_ = false;
176 
177  friend class OverlayImpl;
178 
179  class Metrics
180  {
181  public:
182  Metrics() = default;
183  Metrics(Metrics const&) = delete;
184  Metrics&
185  operator=(Metrics const&) = delete;
186  Metrics(Metrics&&) = delete;
187  Metrics&
188  operator=(Metrics&&) = delete;
189 
190  void
191  add_message(std::uint64_t bytes);
193  average_bytes() const;
195  total_bytes() const;
196 
197  private:
198  boost::shared_mutex mutable mutex_;
199  boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
200  clock_type::time_point intervalStart_{clock_type::now()};
204  };
205 
206  struct
207  {
210  } metrics_;
211 
212 public:
213  PeerImp(PeerImp const&) = delete;
214  PeerImp&
215  operator=(PeerImp const&) = delete;
216 
218  PeerImp(
219  Application& app,
220  id_t id,
222  http_request_type&& request,
223  PublicKey const& publicKey,
225  Resource::Consumer consumer,
226  std::unique_ptr<stream_type>&& stream_ptr,
227  OverlayImpl& overlay);
228 
230  // VFALCO legacyPublicKey should be implied by the Slot
231  template <class Buffers>
232  PeerImp(
233  Application& app,
234  std::unique_ptr<stream_type>&& stream_ptr,
235  Buffers const& buffers,
237  http_response_type&& response,
238  Resource::Consumer usage,
239  PublicKey const& publicKey,
241  id_t id,
242  OverlayImpl& overlay);
243 
244  virtual ~PeerImp();
245 
246  beast::Journal const&
247  pjournal() const
248  {
249  return p_journal_;
250  }
251 
254  {
255  return slot_;
256  }
257 
258  // Work-around for calling shared_from_this in constructors
259  void
260  run();
261 
262  // Called when Overlay gets a stop request.
263  void
264  stop() override;
265 
266  //
267  // Network
268  //
269 
270  void
271  send(std::shared_ptr<Message> const& m) override;
272 
274  template <
275  class FwdIt,
276  class = typename std::enable_if_t<std::is_same<
278  PeerFinder::Endpoint>::value>>
279  void
280  sendEndpoints(FwdIt first, FwdIt last);
281 
283  getRemoteAddress() const override
284  {
285  return remote_address_;
286  }
287 
288  void
289  charge(Resource::Charge const& fee) override;
290 
291  //
292  // Identity
293  //
294 
295  Peer::id_t
296  id() const override
297  {
298  return id_;
299  }
300 
302  bool
303  crawl() const;
304 
305  bool
306  cluster() const override;
307 
311  void
312  checkTracking(std::uint32_t validationSeq);
313 
314  void
316 
317  PublicKey const&
318  getNodePublic() const override
319  {
320  return publicKey_;
321  }
322 
325  getVersion() const;
326 
327  // Return the connection elapsed time.
328  clock_type::duration
329  uptime() const
330  {
331  return clock_type::now() - creationTime_;
332  }
333 
335  json() override;
336 
337  bool
338  supportsFeature(ProtocolFeature f) const override;
339 
340  boost::optional<std::size_t>
341  publisherListSequence(PublicKey const& pubKey) const override
342  {
344 
345  auto iter = publisherListSequences_.find(pubKey);
346  if (iter != publisherListSequences_.end())
347  return iter->second;
348  return {};
349  }
350 
351  void
353  override
354  {
356 
357  publisherListSequences_[pubKey] = seq;
358  }
359 
360  //
361  // Ledger
362  //
363 
364  uint256 const&
365  getClosedLedgerHash() const override
366  {
367  return closedLedgerHash_;
368  }
369 
370  bool
371  hasLedger(uint256 const& hash, std::uint32_t seq) const override;
372 
373  void
374  ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
375 
376  bool
377  hasShard(std::uint32_t shardIndex) const override;
378 
379  bool
380  hasTxSet(uint256 const& hash) const override;
381 
382  void
383  cycleStatus() override;
384 
385  bool
386  hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
387 
388  // Called to determine our priority for querying
389  int
390  getScore(bool haveItem) const override;
391 
392  bool
393  isHighLatency() const override;
394 
395  void
396  fail(std::string const& reason);
397 
399  boost::optional<RangeSet<std::uint32_t>>
400  getShardIndexes() const;
401 
403  boost::optional<hash_map<PublicKey, ShardInfo>>
404  getPeerShardInfo() const;
405 
406  bool
407  compressionEnabled() const override
408  {
410  }
411 
412 private:
413  void
414  close();
415 
416  void
417  fail(std::string const& name, error_code ec);
418 
419  void
420  gracefulClose();
421 
422  void
423  setTimer();
424 
425  void
426  cancelTimer();
427 
428  static std::string
429  makePrefix(id_t id);
430 
431  // Called when the timer wait completes
432  void
433  onTimer(boost::system::error_code const& ec);
434 
435  // Called when SSL shutdown completes
436  void
438 
439  void
440  doAccept();
441 
443  name() const;
444 
446  domain() const;
447 
449  networkID() const;
450 
451  //
452  // protocol message loop
453  //
454 
455  // Starts the protocol message loop
456  void
457  doProtocolStart();
458 
459  // Called when protocol message bytes are received
460  void
461  onReadMessage(error_code ec, std::size_t bytes_transferred);
462 
463  // Called when protocol messages bytes are sent
464  void
465  onWriteMessage(error_code ec, std::size_t bytes_transferred);
466 
467  // Check if reduce-relay feature is enabled and
468  // reduce_relay::WAIT_ON_BOOTUP time passed since the start
469  bool
471 
472 public:
473  //--------------------------------------------------------------------------
474  //
475  // ProtocolStream
476  //
477  //--------------------------------------------------------------------------
478 
479  void
481 
482  void
484  std::uint16_t type,
486  std::size_t size,
487  std::size_t uncompressed_size,
488  bool isCompressed);
489 
490  void
491  onMessageEnd(
492  std::uint16_t type,
494 
495  void
497  void
499  void
501  void
503  void
505  void
507  void
509  void
511  void
513  void
515  void
517  void
519  void
521  void
523  void
525  void
527  void
529  void
531  void
533 
534 private:
535  //--------------------------------------------------------------------------
536  // lockedRecentLock is passed as a reminder to callers that recentLock_
537  // must be locked.
538  void
539  addLedger(
540  uint256 const& hash,
541  std::lock_guard<std::mutex> const& lockedRecentLock);
542 
543  void
545 
546  void
548  std::string const& messageType,
549  std::string const& manifest,
550  std::uint32_t version,
551  std::vector<ValidatorBlobInfo> const& blobs);
552 
553  void
555  int flags,
556  bool checkSignature,
557  std::shared_ptr<STTx const> const& stx);
558 
559  void
560  checkPropose(
561  Job& job,
563  RCLCxPeerPos peerPos);
564 
565  void
569 
570  void
572 };
573 
574 //------------------------------------------------------------------------------
575 
576 template <class Buffers>
578  Application& app,
579  std::unique_ptr<stream_type>&& stream_ptr,
580  Buffers const& buffers,
582  http_response_type&& response,
583  Resource::Consumer usage,
584  PublicKey const& publicKey,
586  id_t id,
587  OverlayImpl& overlay)
588  : Child(overlay)
589  , app_(app)
590  , id_(id)
591  , sink_(app_.journal("Peer"), makePrefix(id))
592  , p_sink_(app_.journal("Protocol"), makePrefix(id))
593  , journal_(sink_)
594  , p_journal_(p_sink_)
595  , stream_ptr_(std::move(stream_ptr))
596  , socket_(stream_ptr_->next_layer().socket())
597  , stream_(*stream_ptr_)
598  , strand_(socket_.get_executor())
599  , timer_(waitable_timer{socket_.get_executor()})
600  , remote_address_(slot->remote_endpoint())
601  , overlay_(overlay)
602  , inbound_(false)
603  , protocol_(protocol)
604  , tracking_(Tracking::unknown)
605  , trackingTime_(clock_type::now())
606  , publicKey_(publicKey)
607  , lastPingTime_(clock_type::now())
608  , creationTime_(clock_type::now())
609  , squelch_(app_.journal("Squelch"))
610  , usage_(usage)
611  , fee_(Resource::feeLightPeer)
612  , slot_(std::move(slot))
613  , response_(std::move(response))
614  , headers_(response_)
615  , compressionEnabled_(
617  headers_,
619  "lz4",
620  app_.config().COMPRESSION)
621  ? Compressed::On
622  : Compressed::Off)
623  , vpReduceRelayEnabled_(peerFeatureEnabled(
624  headers_,
625  FEATURE_VPRR,
626  app_.config().VP_REDUCE_RELAY_ENABLE))
627 {
628  read_buffer_.commit(boost::asio::buffer_copy(
629  read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
630  JLOG(journal_.debug()) << "compression enabled "
631  << (compressionEnabled_ == Compressed::On)
632  << " vp reduce-relay enabled "
633  << vpReduceRelayEnabled_ << " on " << remote_address_
634  << " " << id_;
635 }
636 
637 template <class FwdIt, class>
638 void
639 PeerImp::sendEndpoints(FwdIt first, FwdIt last)
640 {
641  protocol::TMEndpoints tm;
642 
643  while (first != last)
644  {
645  auto& tme2(*tm.add_endpoints_v2());
646  tme2.set_endpoint(first->address.to_string());
647  tme2.set_hops(first->hops);
648  first++;
649  }
650  tm.set_version(2);
651 
652  send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
653 }
654 
655 } // namespace ripple
656 
657 #endif
ripple::PeerImp::ledgerRange
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition: PeerImp.cpp:471
ripple::PeerImp::uptime
clock_type::duration uptime() const
Definition: PeerImp.h:329
ripple::Application
Definition: Application.h:101
ripple::PeerImp::Metrics::Metrics
Metrics()=default
ripple::PeerImp::inbound_
const bool inbound_
Definition: PeerImp.h:93
std::is_same
ripple::PeerImp::recentLock_
std::mutex recentLock_
Definition: PeerImp.h:151
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:80
ripple::PeerImp::socket_
socket_type & socket_
Definition: PeerImp.h:81
ripple::PeerImp::trackingTime_
clock_type::time_point trackingTime_
Definition: PeerImp.h:99
std::string
STL class.
std::shared_ptr
STL class.
ripple::PeerImp::onMessage
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition: PeerImp.cpp:992
ripple::PeerImp::hasTxSet
bool hasTxSet(uint256 const &hash) const override
Definition: PeerImp.cpp:490
ripple::PeerImp::strand_
boost::asio::strand< boost::asio::executor > strand_
Definition: PeerImp.h:83
ripple::PeerImp::recentLedgers_
boost::circular_buffer< uint256 > recentLedgers_
Definition: PeerImp.h:113
ripple::PeerImp::publisherListSequence
boost::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition: PeerImp.h:341
ripple::PeerImp::request_
http_request_type request_
Definition: PeerImp.h:157
ripple::PeerImp::~PeerImp
virtual ~PeerImp()
Definition: PeerImp.cpp:123
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:572
std::pair
ripple::PeerImp::doAccept
void doAccept()
Definition: PeerImp.cpp:724
ripple::Peer::id_t
std::uint32_t id_t
Uniquely identifies a peer.
Definition: ripple/overlay/Peer.h:54
ripple::PeerImp::doProtocolStart
void doProtocolStart()
Definition: PeerImp.cpp:807
std::vector
STL class.
ripple::PeerImp::getScore
int getScore(bool haveItem) const override
Definition: PeerImp.cpp:3002
ripple::PeerImp::recentTxSets_
boost::circular_buffer< uint256 > recentTxSets_
Definition: PeerImp.h:114
ripple::PeerImp::checkValidation
void checkValidation(std::shared_ptr< STValidation > const &val, std::shared_ptr< protocol::TMValidation > const &packet)
Definition: PeerImp.cpp:2577
ripple::PeerImp::checkPropose
void checkPropose(Job &job, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition: PeerImp.cpp:2533
ripple::PeerImp::id
Peer::id_t id() const override
Definition: PeerImp.h:296
ripple::PeerImp::setTimer
void setTimer()
Definition: PeerImp.cpp:612
ripple::PeerImp::getVersion
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition: PeerImp.cpp:313
ripple::PeerImp::slot
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition: PeerImp.h:253
ripple::PeerImp::Metrics::accumBytes_
std::uint64_t accumBytes_
Definition: PeerImp.h:202
std::lock_guard
STL class.
ripple::PeerImp::close
void close()
Definition: PeerImp.cpp:518
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:284
ripple::PeerImp::sink_
beast::WrappedSink sink_
Definition: PeerImp.h:76
ripple::PeerImp::onMessageUnknown
void onMessageUnknown(std::uint16_t type)
Definition: PeerImp.cpp:960
ripple::PeerImp::Metrics::average_bytes
std::uint64_t average_bytes() const
Definition: PeerImp.cpp:3083
ripple::PeerImp::getLedger
void getLedger(std::shared_ptr< protocol::TMGetLedger > const &packet)
Definition: PeerImp.cpp:2673
ripple::PeerImp::ShardInfo::endpoint
beast::IP::Endpoint endpoint
Definition: PeerImp.h:58
ripple::PeerImp::journal_
const beast::Journal journal_
Definition: PeerImp.h:78
ripple::PeerImp::isHighLatency
bool isHighLatency() const override
Definition: PeerImp.cpp:3040
ripple::PeerImp::send
void send(std::shared_ptr< Message > const &m) override
Definition: PeerImp.cpp:230
ripple::ProtocolFeature
ProtocolFeature
Definition: ripple/overlay/Peer.h:38
ripple::PeerImp::onTimer
void onTimer(boost::system::error_code const &ec)
Definition: PeerImp.cpp:647
ripple::PeerImp::lastPingTime_
clock_type::time_point lastPingTime_
Definition: PeerImp.h:118
ripple::PeerImp::creationTime_
const clock_type::time_point creationTime_
Definition: PeerImp.h:119
ripple::PeerImp::doFetchPack
void doFetchPack(const std::shared_ptr< protocol::TMGetObjectByHash > &packet)
Definition: PeerImp.cpp:2425
queue
ripple::PeerImp
Definition: PeerImp.h:48
ripple::PeerImp::socket_type
boost::asio::ip::tcp::socket socket_type
Definition: PeerImp.h:65
ripple::PeerImp::previousLedgerHash_
uint256 previousLedgerHash_
Definition: PeerImp.h:111
ripple::FEATURE_VPRR
static constexpr char FEATURE_VPRR[]
Definition: Handshake.h:132
ripple::PeerImp::Metrics::rollingAvgBytes_
std::uint64_t rollingAvgBytes_
Definition: PeerImp.h:203
ripple::PeerImp::name_
std::string name_
Definition: PeerImp.h:103
ripple::PeerImp::recv
Metrics recv
Definition: PeerImp.h:209
ripple::PeerImp::Metrics::intervalStart_
clock_type::time_point intervalStart_
Definition: PeerImp.h:200
ripple::PeerImp::publicKey_
const PublicKey publicKey_
Definition: PeerImp.h:102
ripple::PeerImp::read_buffer_
boost::beast::multi_buffer read_buffer_
Definition: PeerImp.h:156
ripple::PeerImp::error_code
boost::system::error_code error_code
Definition: PeerImp.h:64
ripple::PeerImp::remote_address_
const beast::IP::Endpoint remote_address_
Definition: PeerImp.h:88
ripple::PeerImp::networkID
std::optional< std::uint32_t > networkID() const
ripple::base_uint< 256 >
ripple::reduce_relay::Squelch
Maintains squelching of relaying messages from validators.
Definition: Squelch.h:38
ripple::PeerImp::Metrics::totalBytes_
std::uint64_t totalBytes_
Definition: PeerImp.h:201
ripple::PeerImp::addLedger
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition: PeerImp.cpp:2409
ripple::PeerImp::sent
Metrics sent
Definition: PeerImp.h:208
ripple::PeerImp::Metrics
Definition: PeerImp.h:179
ripple::PeerImp::gracefulClose
void gracefulClose()
Definition: PeerImp.cpp:591
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
std::enable_if_t
ripple::PeerImp::shardInfo_
hash_map< PublicKey, ShardInfo > shardInfo_
Definition: PeerImp.h:169
ripple::PeerImp::closedLedgerHash_
uint256 closedLedgerHash_
Definition: PeerImp.h:110
ripple::PeerImp::lastPingSeq_
boost::optional< std::uint32_t > lastPingSeq_
Definition: PeerImp.h:117
ripple::PeerImp::detaching_
bool detaching_
Definition: PeerImp.h:100
ripple::PeerImp::onMessageEnd
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition: PeerImp.cpp:983
std::iterator_traits
ripple::PeerImp::getNodePublic
PublicKey const & getNodePublic() const override
Definition: PeerImp.h:318
ripple::PeerImp::stream_
stream_type & stream_
Definition: PeerImp.h:82
ripple::PeerImp::onWriteMessage
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:906
ripple::PeerImp::hasRange
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition: PeerImp.cpp:508
ripple::PeerImp::cycleStatus
void cycleStatus() override
Definition: PeerImp.cpp:498
ripple::PeerImp::app_
Application & app_
Definition: PeerImp.h:74
ripple::PeerImp::crawl
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition: PeerImp.cpp:298
ripple::PeerImp::minLedger_
LedgerIndex minLedger_
Definition: PeerImp.h:108
std::enable_shared_from_this
ripple::FEATURE_COMPR
static constexpr char FEATURE_COMPR[]
Definition: Handshake.h:131
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:454
ripple::PeerImp::Tracking::unknown
@ unknown
cstdint
ripple::PeerImp::address_type
boost::asio::ip::address address_type
Definition: PeerImp.h:68
ripple::Job
Definition: Job.h:82
ripple::PeerImp::headers_
boost::beast::http::fields const & headers_
Definition: PeerImp.h:159
ripple::PeerImp::publisherListSequences_
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition: PeerImp.h:166
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::PeerImp::metrics_
struct ripple::PeerImp::@13 metrics_
ripple::peerFeatureEnabled
bool peerFeatureEnabled(headers const &request, std::string const &feature, std::string value, bool config)
Check if a feature should be enabled for a peer.
Definition: Handshake.h:184
ripple::PeerImp::reduceRelayReady
bool reduceRelayReady()
Definition: PeerImp.cpp:3047
std::uint32_t
ripple::PeerImp::send_queue_
std::queue< std::shared_ptr< Message > > send_queue_
Definition: PeerImp.h:160
ripple::PeerImp::sendEndpoints
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition: PeerImp.h:639
ripple::PeerImp::Metrics::total_bytes
std::uint64_t total_bytes() const
Definition: PeerImp.cpp:3090
ripple::PeerImp::slot_
const std::shared_ptr< PeerFinder::Slot > slot_
Definition: PeerImp.h:155
std::atomic< Tracking >
ripple::PeerImp::Tracking
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition: PeerImp.h:54
ripple::PeerImp::load_event_
std::unique_ptr< LoadEvent > load_event_
Definition: PeerImp.h:163
ripple::PeerImp::protocol_
ProtocolVersion protocol_
Definition: PeerImp.h:96
ripple::PeerImp::p_sink_
beast::WrappedSink p_sink_
Definition: PeerImp.h:77
ripple::PeerImp::vpReduceRelayEnabled_
bool vpReduceRelayEnabled_
Definition: PeerImp.h:175
ripple::PeerImp::waitable_timer
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition: PeerImp.h:71
ripple::PeerImp::onShutdown
void onShutdown(error_code ec)
Definition: PeerImp.cpp:708
ripple::PeerImp::PeerImp
PeerImp(PeerImp const &)=delete
ripple::PeerImp::Metrics::add_message
void add_message(std::uint64_t bytes)
Definition: PeerImp.cpp:3057
ripple::PeerImp::name
std::string name() const
Definition: PeerImp.cpp:790
ripple::PeerImp::timer_
waitable_timer timer_
Definition: PeerImp.h:84
ripple::PeerImp::reduceRelayReady_
static std::atomic_bool reduceRelayReady_
Definition: PeerImp.h:122
ripple::PeerImp::ShardInfo
Definition: PeerImp.h:56
ripple::PeerImp::Tracking::diverged
@ diverged
ripple::PeerImp::gracefulClose_
bool gracefulClose_
Definition: PeerImp.h:161
ripple::PeerImp::latency_
boost::optional< std::chrono::milliseconds > latency_
Definition: PeerImp.h:116
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
protocol
Definition: ValidatorList.h:38
ripple::PeerImp::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: PeerImp.h:69
ripple::PeerImp::squelch_
reduce_relay::Squelch< UptimeClock > squelch_
Definition: PeerImp.h:121
std
STL namespace.
ripple::PeerImp::hasShard
bool hasShard(std::uint32_t shardIndex) const override
Definition: PeerImp.cpp:480
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:199
ripple::PeerImp::maxLedger_
LedgerIndex maxLedger_
Definition: PeerImp.h:109
ripple::PeerImp::run
void run()
Definition: PeerImp.cpp:146
ripple::PeerImp::checkTracking
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition: PeerImp.cpp:1806
ripple::PeerImp::large_sendq_
int large_sendq_
Definition: PeerImp.h:162
ripple::PeerImp::pjournal
beast::Journal const & pjournal() const
Definition: PeerImp.h:247
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:797
ripple::Resource::feeLightPeer
const Charge feeLightPeer
ripple::PeerImp::last_status_
protocol::TMStatusChange last_status_
Definition: PeerImp.h:152
ripple::PeerImp::setPublisherListSequence
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition: PeerImp.h:352
ripple::PeerImp::supportsFeature
bool supportsFeature(ProtocolFeature f) const override
Definition: PeerImp.cpp:439
ripple::PeerImp::getClosedLedgerHash
uint256 const & getClosedLedgerHash() const override
Definition: PeerImp.h:365
std::optional< std::uint32_t >
std::mutex
STL class.
ripple::PeerImp::onMessageBegin
void onMessageBegin(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m, std::size_t size, std::size_t uncompressed_size, bool isCompressed)
Definition: PeerImp.cpp:966
std::size_t
ripple::PeerImp::json
Json::Value json() override
Definition: PeerImp.cpp:321
ripple::PeerImp::compressionEnabled_
Compressed compressionEnabled_
Definition: PeerImp.h:171
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:639
ripple::PeerImp::usage_
Resource::Consumer usage_
Definition: PeerImp.h:153
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:198
ripple::PeerImp::checkTransaction
void checkTransaction(int flags, bool checkSignature, std::shared_ptr< STTx const > const &stx)
Definition: PeerImp.cpp:2459
ripple::PeerImp::middle_type
boost::beast::tcp_stream middle_type
Definition: PeerImp.h:66
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:582
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:158
ripple::PeerImp::shardInfoMutex_
std::mutex shardInfoMutex_
Definition: PeerImp.h:168
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:60
ripple::PeerImp::overlay_
OverlayImpl & overlay_
Definition: PeerImp.h:92
ripple::PeerImp::compressionEnabled
bool compressionEnabled() const override
Definition: PeerImp.h:407
ripple::PeerImp::getRemoteAddress
beast::IP::Endpoint getRemoteAddress() const override
Definition: PeerImp.h:283
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handshake.h:47
std::unique_ptr< stream_type >
ripple::PeerImp::stream_type
boost::beast::ssl_stream< middle_type > stream_type
Definition: PeerImp.h:67
ripple::PeerImp::tracking_
std::atomic< Tracking > tracking_
Definition: PeerImp.h:98
ripple::PeerImp::nameMutex_
boost::shared_mutex nameMutex_
Definition: PeerImp.h:104
ripple::PeerImp::cancelTimer
void cancelTimer()
Definition: PeerImp.cpp:630
std::unordered_map
STL class.
ripple::http_response_type
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
Definition: Handshake.h:49
ripple::PeerImp::fee_
Resource::Charge fee_
Definition: PeerImp.h:154
ripple::PeerImp::stop
void stop() override
Definition: PeerImp.cpp:204
ripple::PeerImp::Tracking::converged
@ converged
ripple::PeerImp::id_
const id_t id_
Definition: PeerImp.h:75
ripple::PeerImp::fail
void fail(std::string const &reason)
Definition: PeerImp.cpp:540
ripple::PeerImp::cluster
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition: PeerImp.cpp:307
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:79
ripple::Peer
Represents a peer connection in the overlay.
Definition: ripple/overlay/Peer.h:44
ripple::PeerImp::ShardInfo::shardIndexes
RangeSet< std::uint32_t > shardIndexes
Definition: PeerImp.h:59
ripple::PeerImp::Metrics::operator=
Metrics & operator=(Metrics const &)=delete
ripple::PeerImp::onValidatorListMessage
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
Definition: PeerImp.cpp:1873
ripple::PeerImp::onReadMessage
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:850
std::chrono::steady_clock::now
T now(T... args)