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/app/ledger/impl/LedgerReplayMsgHandler.h>
25 #include <ripple/basics/Log.h>
26 #include <ripple/basics/RangeSet.h>
27 #include <ripple/basics/UnorderedContainers.h>
28 #include <ripple/beast/utility/WrappedSink.h>
29 #include <ripple/nodestore/ShardInfo.h>
30 #include <ripple/overlay/Squelch.h>
31 #include <ripple/overlay/impl/OverlayImpl.h>
32 #include <ripple/overlay/impl/ProtocolMessage.h>
33 #include <ripple/overlay/impl/ProtocolVersion.h>
34 #include <ripple/peerfinder/PeerfinderManager.h>
35 #include <ripple/protocol/Protocol.h>
36 #include <ripple/protocol/STTx.h>
37 #include <ripple/protocol/STValidation.h>
38 #include <ripple/resource/Fees.h>
39 
40 #include <boost/circular_buffer.hpp>
41 #include <boost/endian/conversion.hpp>
42 #include <boost/thread/shared_mutex.hpp>
43 #include <cstdint>
44 #include <optional>
45 #include <queue>
46 
47 namespace ripple {
48 
49 struct ValidatorBlobInfo;
50 class SHAMap;
51 
52 class PeerImp : public Peer,
53  public std::enable_shared_from_this<PeerImp>,
54  public OverlayImpl::Child
55 {
56 public:
58  enum class Tracking { diverged, unknown, converged };
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 
116  clock_type::time_point lastPingTime_;
117  clock_type::time_point const creationTime_;
118 
120  inline static std::atomic_bool reduceRelayReady_{false};
121 
122  // Notes on thread locking:
123  //
124  // During an audit it was noted that some member variables that looked
125  // like they need thread protection were not receiving it. And, indeed,
126  // that was correct. But the multi-phase initialization of PeerImp
127  // makes such an audit difficult. A further audit suggests that the
128  // locking is now protecting variables that don't need it. We're
129  // leaving that locking in place (for now) as a form of future proofing.
130  //
131  // Here are the variables that appear to need locking currently:
132  //
133  // o closedLedgerHash_
134  // o previousLedgerHash_
135  // o minLedger_
136  // o maxLedger_
137  // o recentLedgers_
138  // o recentTxSets_
139  // o trackingTime_
140  // o latency_
141  //
142  // The following variables are being protected preemptively:
143  //
144  // o name_
145  // o last_status_
146  //
147  // June 2019
148 
150  protocol::TMStatusChange last_status_;
154  boost::beast::multi_buffer read_buffer_;
157  boost::beast::http::fields const& headers_;
159  bool gracefulClose_ = false;
160  int large_sendq_ = 0;
162  // The highest sequence of each PublisherList that has
163  // been sent to or received from this peer.
165 
166  // Any known shard info from this peer and its sub peers
169 
171 
172  // Queue of transactions' hashes that have not been
173  // relayed. The hashes are sent once a second to a peer
174  // and the peer requests missing transactions from the node.
176  // true if tx reduce-relay feature is enabled on the peer.
177  bool txReduceRelayEnabled_ = false;
178  // true if validation/proposal reduce-relay feature is enabled
179  // on the peer.
180  bool vpReduceRelayEnabled_ = false;
181  bool ledgerReplayEnabled_ = false;
183 
184  friend class OverlayImpl;
185 
186  class Metrics
187  {
188  public:
189  Metrics() = default;
190  Metrics(Metrics const&) = delete;
191  Metrics&
192  operator=(Metrics const&) = delete;
193  Metrics(Metrics&&) = delete;
194  Metrics&
195  operator=(Metrics&&) = delete;
196 
197  void
198  add_message(std::uint64_t bytes);
200  average_bytes() const;
202  total_bytes() const;
203 
204  private:
205  boost::shared_mutex mutable mutex_;
206  boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
207  clock_type::time_point intervalStart_{clock_type::now()};
211  };
212 
213  struct
214  {
217  } metrics_;
218 
219 public:
220  PeerImp(PeerImp const&) = delete;
221  PeerImp&
222  operator=(PeerImp const&) = delete;
223 
225  PeerImp(
226  Application& app,
227  id_t id,
229  http_request_type&& request,
230  PublicKey const& publicKey,
232  Resource::Consumer consumer,
233  std::unique_ptr<stream_type>&& stream_ptr,
234  OverlayImpl& overlay);
235 
237  // VFALCO legacyPublicKey should be implied by the Slot
238  template <class Buffers>
239  PeerImp(
240  Application& app,
241  std::unique_ptr<stream_type>&& stream_ptr,
242  Buffers const& buffers,
244  http_response_type&& response,
245  Resource::Consumer usage,
246  PublicKey const& publicKey,
248  id_t id,
249  OverlayImpl& overlay);
250 
251  virtual ~PeerImp();
252 
253  beast::Journal const&
254  pjournal() const
255  {
256  return p_journal_;
257  }
258 
261  {
262  return slot_;
263  }
264 
265  // Work-around for calling shared_from_this in constructors
266  virtual void
267  run();
268 
269  // Called when Overlay gets a stop request.
270  void
271  stop() override;
272 
273  //
274  // Network
275  //
276 
277  void
278  send(std::shared_ptr<Message> const& m) override;
279 
281  void
282  sendTxQueue() override;
283 
287  void
288  addTxQueue(uint256 const& hash) override;
289 
293  void
294  removeTxQueue(uint256 const& hash) override;
295 
297  template <
298  class FwdIt,
299  class = typename std::enable_if_t<std::is_same<
301  PeerFinder::Endpoint>::value>>
302  void
303  sendEndpoints(FwdIt first, FwdIt last);
304 
306  getRemoteAddress() const override
307  {
308  return remote_address_;
309  }
310 
311  void
312  charge(Resource::Charge const& fee) override;
313 
314  //
315  // Identity
316  //
317 
318  Peer::id_t
319  id() const override
320  {
321  return id_;
322  }
323 
325  bool
326  crawl() const;
327 
328  bool
329  cluster() const override;
330 
334  void
335  checkTracking(std::uint32_t validationSeq);
336 
337  void
339 
340  PublicKey const&
341  getNodePublic() const override
342  {
343  return publicKey_;
344  }
345 
348  getVersion() const;
349 
350  // Return the connection elapsed time.
351  clock_type::duration
352  uptime() const
353  {
354  return clock_type::now() - creationTime_;
355  }
356 
358  json() override;
359 
360  bool
361  supportsFeature(ProtocolFeature f) const override;
362 
364  publisherListSequence(PublicKey const& pubKey) const override
365  {
367 
368  auto iter = publisherListSequences_.find(pubKey);
369  if (iter != publisherListSequences_.end())
370  return iter->second;
371  return {};
372  }
373 
374  void
376  override
377  {
379 
380  publisherListSequences_[pubKey] = seq;
381  }
382 
383  //
384  // Ledger
385  //
386 
387  uint256 const&
388  getClosedLedgerHash() const override
389  {
390  return closedLedgerHash_;
391  }
392 
393  bool
394  hasLedger(uint256 const& hash, std::uint32_t seq) const override;
395 
396  void
397  ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
398 
399  bool
400  hasTxSet(uint256 const& hash) const override;
401 
402  void
403  cycleStatus() override;
404 
405  bool
406  hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
407 
408  // Called to determine our priority for querying
409  int
410  getScore(bool haveItem) const override;
411 
412  bool
413  isHighLatency() const override;
414 
415  void
416  fail(std::string const& reason);
417 
418  // Return any known shard info from this peer and its sub peers
420  getPeerShardInfos() const;
421 
422  bool
423  compressionEnabled() const override
424  {
426  }
427 
428  bool
429  txReduceRelayEnabled() const override
430  {
431  return txReduceRelayEnabled_;
432  }
433 
434 private:
435  void
436  close();
437 
438  void
439  fail(std::string const& name, error_code ec);
440 
441  void
442  gracefulClose();
443 
444  void
445  setTimer();
446 
447  void
448  cancelTimer();
449 
450  static std::string
451  makePrefix(id_t id);
452 
453  // Called when the timer wait completes
454  void
455  onTimer(boost::system::error_code const& ec);
456 
457  // Called when SSL shutdown completes
458  void
460 
461  void
462  doAccept();
463 
465  name() const;
466 
468  domain() const;
469 
470  //
471  // protocol message loop
472  //
473 
474  // Starts the protocol message loop
475  void
476  doProtocolStart();
477 
478  // Called when protocol message bytes are received
479  void
480  onReadMessage(error_code ec, std::size_t bytes_transferred);
481 
482  // Called when protocol messages bytes are sent
483  void
484  onWriteMessage(error_code ec, std::size_t bytes_transferred);
485 
495  void
498  bool eraseTxQueue);
499 
505  void
508 
509  // Check if reduce-relay feature is enabled and
510  // reduce_relay::WAIT_ON_BOOTUP time passed since the start
511  bool
513 
514 public:
515  //--------------------------------------------------------------------------
516  //
517  // ProtocolStream
518  //
519  //--------------------------------------------------------------------------
520 
521  void
523 
524  void
526  std::uint16_t type,
528  std::size_t size,
529  std::size_t uncompressed_size,
530  bool isCompressed);
531 
532  void
533  onMessageEnd(
534  std::uint16_t type,
536 
537  void
539  void
541  void
543  void
545  void
547  void
549  void
551  void
553  void
555  void
557  void
559  void
561  void
563  void
565  void
567  void
569  void
571  void
573  void
575  void
577  void
579  void
581  void
583  void
585  void
587 
588 private:
589  //--------------------------------------------------------------------------
590  // lockedRecentLock is passed as a reminder to callers that recentLock_
591  // must be locked.
592  void
593  addLedger(
594  uint256 const& hash,
595  std::lock_guard<std::mutex> const& lockedRecentLock);
596 
597  void
599 
600  void
602  std::string const& messageType,
603  std::string const& manifest,
604  std::uint32_t version,
605  std::vector<ValidatorBlobInfo> const& blobs);
606 
611  void
613 
614  void
616  int flags,
617  bool checkSignature,
618  std::shared_ptr<STTx const> const& stx);
619 
620  void
621  checkPropose(
622  bool isTrusted,
624  RCLCxPeerPos peerPos);
625 
626  void
629  uint256 const& key,
631 
632  void
634  std::shared_ptr<Ledger const> const& ledger,
635  protocol::TMLedgerData& ledgerData);
636 
639 
642 
643  void
645 };
646 
647 //------------------------------------------------------------------------------
648 
649 template <class Buffers>
651  Application& app,
652  std::unique_ptr<stream_type>&& stream_ptr,
653  Buffers const& buffers,
655  http_response_type&& response,
656  Resource::Consumer usage,
657  PublicKey const& publicKey,
659  id_t id,
660  OverlayImpl& overlay)
661  : Child(overlay)
662  , app_(app)
663  , id_(id)
664  , sink_(app_.journal("Peer"), makePrefix(id))
665  , p_sink_(app_.journal("Protocol"), makePrefix(id))
666  , journal_(sink_)
667  , p_journal_(p_sink_)
668  , stream_ptr_(std::move(stream_ptr))
669  , socket_(stream_ptr_->next_layer().socket())
670  , stream_(*stream_ptr_)
671  , strand_(socket_.get_executor())
672  , timer_(waitable_timer{socket_.get_executor()})
673  , remote_address_(slot->remote_endpoint())
674  , overlay_(overlay)
675  , inbound_(false)
676  , protocol_(protocol)
677  , tracking_(Tracking::unknown)
678  , trackingTime_(clock_type::now())
679  , publicKey_(publicKey)
680  , lastPingTime_(clock_type::now())
681  , creationTime_(clock_type::now())
682  , squelch_(app_.journal("Squelch"))
683  , usage_(usage)
684  , fee_(Resource::feeLightPeer)
685  , slot_(std::move(slot))
686  , response_(std::move(response))
687  , headers_(response_)
688  , compressionEnabled_(
690  headers_,
692  "lz4",
693  app_.config().COMPRESSION)
694  ? Compressed::On
695  : Compressed::Off)
696  , txReduceRelayEnabled_(peerFeatureEnabled(
697  headers_,
698  FEATURE_TXRR,
699  app_.config().TX_REDUCE_RELAY_ENABLE))
700  , vpReduceRelayEnabled_(peerFeatureEnabled(
701  headers_,
702  FEATURE_VPRR,
703  app_.config().VP_REDUCE_RELAY_ENABLE))
704  , ledgerReplayEnabled_(peerFeatureEnabled(
705  headers_,
707  app_.config().LEDGER_REPLAY))
708  , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
709 {
710  read_buffer_.commit(boost::asio::buffer_copy(
711  read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
712  JLOG(journal_.info()) << "compression enabled "
713  << (compressionEnabled_ == Compressed::On)
714  << " vp reduce-relay enabled "
715  << vpReduceRelayEnabled_
716  << " tx reduce-relay enabled "
717  << txReduceRelayEnabled_ << " on " << remote_address_
718  << " " << id_;
719 }
720 
721 template <class FwdIt, class>
722 void
723 PeerImp::sendEndpoints(FwdIt first, FwdIt last)
724 {
725  protocol::TMEndpoints tm;
726 
727  while (first != last)
728  {
729  auto& tme2(*tm.add_endpoints_v2());
730  tme2.set_endpoint(first->address.to_string());
731  tme2.set_hops(first->hops);
732  first++;
733  }
734  tm.set_version(2);
735 
736  send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
737 }
738 
739 } // namespace ripple
740 
741 #endif
ripple::PeerImp::latency_
std::optional< std::chrono::milliseconds > latency_
Definition: PeerImp.h:114
ripple::PeerImp::ledgerRange
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition: PeerImp.cpp:541
ripple::PeerImp::uptime
clock_type::duration uptime() const
Definition: PeerImp.h:352
ripple::Application
Definition: Application.h:115
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:149
std::chrono::steady_clock
ripple::RCLCxPeerPos
A peer's signed, proposed position for use in RCLConsensus.
Definition: RCLCxPeerPos.h:43
ripple::compression::Compressed::On
@ On
ripple::PeerImp::stream_ptr_
std::unique_ptr< stream_type > stream_ptr_
Definition: PeerImp.h:78
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::addTxQueue
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition: PeerImp.cpp:314
ripple::PeerImp::onMessage
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition: PeerImp.cpp:1052
ripple::PeerImp::hasTxSet
bool hasTxSet(uint256 const &hash) const override
Definition: PeerImp.cpp:550
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::ledgerReplayEnabled_
bool ledgerReplayEnabled_
Definition: PeerImp.h:181
ripple::PeerImp::request_
http_request_type request_
Definition: PeerImp.h:155
std::unordered_set
STL class.
ripple::PeerImp::~PeerImp
virtual ~PeerImp()
Definition: PeerImp.cpp:134
std::pair
ripple::PeerImp::doAccept
void doAccept()
Definition: PeerImp.cpp:767
ripple::PeerImp::checkPropose
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition: PeerImp.cpp:3125
ripple::PeerImp::handleTransaction
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue)
Called from onMessage(TMTransaction(s)).
Definition: PeerImp.cpp:1522
ripple::Peer::id_t
std::uint32_t id_t
Uniquely identifies a peer.
Definition: ripple/overlay/Peer.h:55
ripple::PeerImp::doProtocolStart
void doProtocolStart()
Definition: PeerImp.cpp:850
std::vector
STL class.
ripple::PeerImp::getScore
int getScore(bool haveItem) const override
Definition: PeerImp.cpp:3620
ripple::PeerImp::recentTxSets_
boost::circular_buffer< uint256 > recentTxSets_
Definition: PeerImp.h:112
ripple::PeerImp::sendTxQueue
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition: PeerImp.cpp:295
ripple::PeerImp::txReduceRelayEnabled
bool txReduceRelayEnabled() const override
Definition: PeerImp.h:429
ripple::FEATURE_LEDGER_REPLAY
static constexpr char FEATURE_LEDGER_REPLAY[]
Definition: Handshake.h:148
ripple::PeerImp::id
Peer::id_t id() const override
Definition: PeerImp.h:319
ripple::PeerImp::setTimer
void setTimer()
Definition: PeerImp.cpp:655
ripple::PeerImp::getVersion
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition: PeerImp.cpp:372
ripple::PeerImp::slot
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition: PeerImp.h:260
ripple::PeerImp::Metrics::accumBytes_
std::uint64_t accumBytes_
Definition: PeerImp.h:209
std::lock_guard
STL class.
ripple::PeerImp::close
void close()
Definition: PeerImp.cpp:578
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:343
ripple::PeerImp::sink_
beast::WrappedSink sink_
Definition: PeerImp.h:74
ripple::PeerImp::onMessageUnknown
void onMessageUnknown(std::uint16_t type)
Definition: PeerImp.cpp:1003
ripple::PeerImp::Metrics::average_bytes
std::uint64_t average_bytes() const
Definition: PeerImp.cpp:3701
ripple::PeerImp::journal_
const beast::Journal journal_
Definition: PeerImp.h:76
ripple::PeerImp::isHighLatency
bool isHighLatency() const override
Definition: PeerImp.cpp:3658
ripple::PeerImp::send
void send(std::shared_ptr< Message > const &m) override
Definition: PeerImp.cpp:241
ripple::ProtocolFeature
ProtocolFeature
Definition: ripple/overlay/Peer.h:38
ripple::PeerImp::onTimer
void onTimer(boost::system::error_code const &ec)
Definition: PeerImp.cpp:690
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:2960
queue
ripple::PeerImp::getLedger
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3302
ripple::PeerImp
Definition: PeerImp.h:52
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::FEATURE_VPRR
static constexpr char FEATURE_VPRR[]
Definition: Handshake.h:144
ripple::PeerImp::Metrics::rollingAvgBytes_
std::uint64_t rollingAvgBytes_
Definition: PeerImp.h:210
ripple::PeerImp::txQueue_
hash_set< uint256 > txQueue_
Definition: PeerImp.h:175
ripple::PeerImp::name_
std::string name_
Definition: PeerImp.h:101
ripple::PeerImp::recv
Metrics recv
Definition: PeerImp.h:216
ripple::PeerImp::Metrics::intervalStart_
clock_type::time_point intervalStart_
Definition: PeerImp.h:207
ripple::PeerImp::publicKey_
const PublicKey publicKey_
Definition: PeerImp.h:100
ripple::PeerImp::read_buffer_
boost::beast::multi_buffer read_buffer_
Definition: PeerImp.h:154
ripple::PeerImp::error_code
boost::system::error_code error_code
Definition: PeerImp.h:62
ripple::FEATURE_TXRR
static constexpr char FEATURE_TXRR[]
Definition: Handshake.h:146
ripple::PeerImp::remote_address_
const beast::IP::Endpoint remote_address_
Definition: PeerImp.h:86
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:82
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:208
ripple::PeerImp::addLedger
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition: PeerImp.cpp:2944
ripple::PeerImp::sent
Metrics sent
Definition: PeerImp.h:215
ripple::PeerImp::Metrics
Definition: PeerImp.h:186
ripple::PeerImp::gracefulClose
void gracefulClose()
Definition: PeerImp.cpp:639
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
std::enable_if_t
ripple::PeerImp::closedLedgerHash_
uint256 closedLedgerHash_
Definition: PeerImp.h:108
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:1043
std::iterator_traits
ripple::PeerImp::getNodePublic
PublicKey const & getNodePublic() const override
Definition: PeerImp.h:341
ripple::PeerImp::shardInfos_
hash_map< PublicKey, NodeStore::ShardInfo > shardInfos_
Definition: PeerImp.h:167
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:949
ripple::PeerImp::hasRange
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition: PeerImp.cpp:568
ripple::PeerImp::cycleStatus
void cycleStatus() override
Definition: PeerImp.cpp:558
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:357
ripple::PeerImp::minLedger_
LedgerIndex minLedger_
Definition: PeerImp.h:106
std::enable_shared_from_this
ripple::FEATURE_COMPR
static constexpr char FEATURE_COMPR[]
Definition: Handshake.h:142
ripple::compression::Compressed::Off
@ Off
ripple::compression::Compressed
Compressed
Definition: Compression.h:38
ripple::PeerImp::ledgerReplayMsgHandler_
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition: PeerImp.h:182
ripple::PeerImp::hasLedger
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition: PeerImp.cpp:515
ripple::PeerImp::Tracking::unknown
@ unknown
cstdint
ripple::PeerImp::address_type
boost::asio::ip::address address_type
Definition: PeerImp.h:66
ripple::PeerImp::headers_
boost::beast::http::fields const & headers_
Definition: PeerImp.h:157
ripple::PeerImp::publisherListSequences_
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition: PeerImp.h:164
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:199
ripple::PeerImp::reduceRelayReady
bool reduceRelayReady()
Definition: PeerImp.cpp:3665
std::uint32_t
ripple::PeerImp::send_queue_
std::queue< std::shared_ptr< Message > > send_queue_
Definition: PeerImp.h:158
ripple::PeerImp::sendEndpoints
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition: PeerImp.h:723
ripple::PeerImp::Metrics::total_bytes
std::uint64_t total_bytes() const
Definition: PeerImp.cpp:3708
ripple::PeerImp::slot_
const std::shared_ptr< PeerFinder::Slot > slot_
Definition: PeerImp.h:153
std::atomic< Tracking >
ripple::PeerImp::Tracking
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition: PeerImp.h:58
ripple::PeerImp::load_event_
std::unique_ptr< LoadEvent > load_event_
Definition: PeerImp.h:161
ripple::PeerImp::processLedgerRequest
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3448
ripple::PeerImp::protocol_
ProtocolVersion protocol_
Definition: PeerImp.h:94
ripple::PeerImp::p_sink_
beast::WrappedSink p_sink_
Definition: PeerImp.h:75
ripple::PeerImp::vpReduceRelayEnabled_
bool vpReduceRelayEnabled_
Definition: PeerImp.h:180
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:751
ripple::PeerImp::PeerImp
PeerImp(PeerImp const &)=delete
ripple::PeerImp::Metrics::add_message
void add_message(std::uint64_t bytes)
Definition: PeerImp.cpp:3675
ripple::PeerImp::name
std::string name() const
Definition: PeerImp.cpp:833
ripple::PeerImp::timer_
waitable_timer timer_
Definition: PeerImp.h:82
ripple::PeerImp::reduceRelayReady_
static std::atomic_bool reduceRelayReady_
Definition: PeerImp.h:120
ripple::PeerImp::getTxSet
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition: PeerImp.cpp:3413
ripple::PeerImp::txReduceRelayEnabled_
bool txReduceRelayEnabled_
Definition: PeerImp.h:177
ripple::PeerImp::Tracking::diverged
@ diverged
ripple::PeerImp::gracefulClose_
bool gracefulClose_
Definition: PeerImp.h:159
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::LedgerReplayMsgHandler
Definition: LedgerReplayMsgHandler.h:30
ripple::PeerImp::handleHaveTransactions
void handleHaveTransactions(std::shared_ptr< protocol::TMHaveTransactions > const &m)
Handle protocol message with hashes of transactions that have not been relayed by an upstream node do...
Definition: PeerImp.cpp:2815
protocol
Definition: ValidatorList.h:38
ripple::PeerImp::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: PeerImp.h:67
ripple::PeerImp::squelch_
reduce_relay::Squelch< UptimeClock > squelch_
Definition: PeerImp.h:119
ripple::PeerImp::publisherListSequence
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition: PeerImp.h:364
ripple::PeerImp::lastPingSeq_
std::optional< std::uint32_t > lastPingSeq_
Definition: PeerImp.h:115
std
STL namespace.
ripple::Resource::Consumer
An endpoint that consumes resources.
Definition: Consumer.h:34
ripple::Resource::Charge
A consumption charge.
Definition: Charge.h:30
ripple::PeerImp::Metrics::rollingAvg_
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition: PeerImp.h:206
ripple::PeerImp::maxLedger_
LedgerIndex maxLedger_
Definition: PeerImp.h:107
ripple::PeerImp::run
virtual void run()
Definition: PeerImp.cpp:157
ripple::PeerImp::checkTracking
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition: PeerImp.cpp:2193
ripple::PeerImp::large_sendq_
int large_sendq_
Definition: PeerImp.h:160
ripple::PeerImp::pjournal
beast::Journal const & pjournal() const
Definition: PeerImp.h:254
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:840
ripple::Resource::feeLightPeer
const Charge feeLightPeer
ripple::PeerImp::last_status_
protocol::TMStatusChange last_status_
Definition: PeerImp.h:150
ripple::PeerImp::setPublisherListSequence
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition: PeerImp.h:375
ripple::PeerImp::supportsFeature
bool supportsFeature(ProtocolFeature f) const override
Definition: PeerImp.cpp:498
ripple::PeerImp::getClosedLedgerHash
uint256 const & getClosedLedgerHash() const override
Definition: PeerImp.h:388
optional
std::mutex
STL class.
ripple::PeerImp::getPeerShardInfos
const hash_map< PublicKey, NodeStore::ShardInfo > getPeerShardInfos() const
Definition: PeerImp.cpp:632
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:1009
std::size_t
ripple::PeerImp::json
Json::Value json() override
Definition: PeerImp.cpp:380
ripple::PeerImp::compressionEnabled_
Compressed compressionEnabled_
Definition: PeerImp.h:170
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
ripple::PeerImp::makePrefix
static std::string makePrefix(id_t id)
Definition: PeerImp.cpp:682
ripple::PeerImp::usage_
Resource::Consumer usage_
Definition: PeerImp.h:151
ripple::PeerImp::sendLedgerBase
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition: PeerImp.cpp:3262
ripple::PeerImp::Metrics::mutex_
boost::shared_mutex mutex_
Definition: PeerImp.h:205
ripple::PeerImp::checkTransaction
void checkTransaction(int flags, bool checkSignature, std::shared_ptr< STTx const > const &stx)
Definition: PeerImp.cpp:3049
ripple::PeerImp::middle_type
boost::beast::tcp_stream middle_type
Definition: PeerImp.h:64
ripple::PeerImp::checkValidation
void checkValidation(std::shared_ptr< STValidation > const &val, uint256 const &key, std::shared_ptr< protocol::TMValidation > const &packet)
Definition: PeerImp.cpp:3167
ripple::OverlayImpl
Definition: OverlayImpl.h:58
ripple::PeerFinder::Endpoint
Describes a connectible peer address along with some metadata.
Definition: PeerfinderManager.h:113
ripple::PeerImp::response_
http_response_type response_
Definition: PeerImp.h:156
ripple::PeerImp::shardInfoMutex_
std::mutex shardInfoMutex_
Definition: PeerImp.h:168
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:61
ripple::PeerImp::overlay_
OverlayImpl & overlay_
Definition: PeerImp.h:90
ripple::PeerImp::compressionEnabled
bool compressionEnabled() const override
Definition: PeerImp.h:423
ripple::PeerImp::getRemoteAddress
beast::IP::Endpoint getRemoteAddress() const override
Definition: PeerImp.h:306
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: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:673
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:152
ripple::PeerImp::stop
void stop() override
Definition: PeerImp.cpp:215
ripple::PeerImp::doTransactions
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
Definition: PeerImp.cpp:2994
ripple::PeerImp::removeTxQueue
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition: PeerImp.cpp:331
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:600
ripple::PeerImp::cluster
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition: PeerImp.cpp:366
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:45
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:2260
ripple::PeerImp::onReadMessage
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:893
std::chrono::steady_clock::now
T now(T... args)