rippled
OverlayImpl.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_OVERLAYIMPL_H_INCLUDED
21 #define RIPPLE_OVERLAY_OVERLAYIMPL_H_INCLUDED
22 
23 #include <ripple/app/main/Application.h>
24 #include <ripple/basics/Resolver.h>
25 #include <ripple/basics/UnorderedContainers.h>
26 #include <ripple/basics/chrono.h>
27 #include <ripple/core/Job.h>
28 #include <ripple/overlay/Message.h>
29 #include <ripple/overlay/Overlay.h>
30 #include <ripple/overlay/Slot.h>
31 #include <ripple/overlay/impl/Handshake.h>
32 #include <ripple/overlay/impl/TrafficCount.h>
33 #include <ripple/overlay/impl/TxMetrics.h>
34 #include <ripple/peerfinder/PeerfinderManager.h>
35 #include <ripple/resource/ResourceManager.h>
36 #include <ripple/rpc/ServerHandler.h>
37 #include <ripple/server/Handoff.h>
38 #include <boost/asio/basic_waitable_timer.hpp>
39 #include <boost/asio/ip/tcp.hpp>
40 #include <boost/asio/ssl/context.hpp>
41 #include <boost/asio/strand.hpp>
42 #include <boost/container/flat_map.hpp>
43 #include <atomic>
44 #include <cassert>
45 #include <chrono>
46 #include <condition_variable>
47 #include <cstdint>
48 #include <memory>
49 #include <mutex>
50 #include <optional>
51 #include <unordered_map>
52 
53 namespace ripple {
54 
55 class PeerImp;
56 class BasicConfig;
57 
59 {
60 public:
61  class Child
62  {
63  protected:
65 
66  explicit Child(OverlayImpl& overlay);
67 
68  virtual ~Child();
69 
70  public:
71  virtual void
72  stop() = 0;
73  };
74 
75 private:
77  using socket_type = boost::asio::ip::tcp::socket;
78  using address_type = boost::asio::ip::address;
79  using endpoint_type = boost::asio::ip::tcp::endpoint;
80  using error_code = boost::system::error_code;
81 
83  {
84  boost::asio::basic_waitable_timer<clock_type> timer_;
85  bool stopping_{false};
86 
87  explicit Timer(OverlayImpl& overlay);
88 
89  void
90  stop() override;
91 
92  void
93  async_wait();
94 
95  void
96  on_timer(error_code ec);
97  };
98 
100  boost::asio::io_service& io_service_;
102  boost::asio::io_service::strand strand_;
103  mutable std::recursive_mutex mutex_; // VFALCO use std::mutex
106  boost::container::flat_map<Child*, std::weak_ptr<Child>> list_;
107  Setup setup_;
121 
122  // 'cs' = crawl shards
125  // Peer IDs expecting to receive a last link notification
127 
129 
131 
132  // Transaction reduce-relay metrics
134 
135  // A message with the list of manifests we send to peers
137  // Used to track whether we need to update the cached list of manifests
139  // Protects the message and the sequence list of manifests
141 
142  //--------------------------------------------------------------------------
143 
144 public:
145  OverlayImpl(
146  Application& app,
147  Setup const& setup,
148  ServerHandler& serverHandler,
150  Resolver& resolver,
151  boost::asio::io_service& io_service,
152  BasicConfig const& config,
153  beast::insight::Collector::ptr const& collector);
154 
155  OverlayImpl(OverlayImpl const&) = delete;
156  OverlayImpl&
157  operator=(OverlayImpl const&) = delete;
158 
159  void
160  start() override;
161 
162  void
163  stop() override;
164 
167  {
168  return *m_peerFinder;
169  }
170 
173  {
174  return m_resourceManager;
175  }
176 
177  Setup const&
178  setup() const
179  {
180  return setup_;
181  }
182 
183  Handoff
184  onHandoff(
186  http_request_type&& request,
187  endpoint_type remote_endpoint) override;
188 
189  void
190  connect(beast::IP::Endpoint const& remote_endpoint) override;
191 
192  int
193  limit() override;
194 
196  size() const override;
197 
199  json() override;
200 
202  getActivePeers() const override;
203 
215  std::set<Peer::id_t> const& toSkip,
216  std::size_t& active,
217  std::size_t& disabled,
218  std::size_t& enabledInSkip) const;
219 
220  void checkTracking(std::uint32_t) override;
221 
223  findPeerByShortID(Peer::id_t const& id) const override;
224 
226  findPeerByPublicKey(PublicKey const& pubKey) override;
227 
228  void
229  broadcast(protocol::TMProposeSet& m) override;
230 
231  void
232  broadcast(protocol::TMValidation& m) override;
233 
235  relay(
236  protocol::TMProposeSet& m,
237  uint256 const& uid,
238  PublicKey const& validator) override;
239 
241  relay(
242  protocol::TMValidation& m,
243  uint256 const& uid,
244  PublicKey const& validator) override;
245 
246  void
247  relay(
248  uint256 const&,
249  protocol::TMTransaction& m,
250  std::set<Peer::id_t> const& skip) override;
251 
254 
255  //--------------------------------------------------------------------------
256  //
257  // OverlayImpl
258  //
259 
260  void
262 
263  void
265 
271  void
272  activate(std::shared_ptr<PeerImp> const& peer);
273 
274  // Called when an active peer is destroyed.
275  void
277 
278  // UnaryFunc will be called as
279  // void(std::shared_ptr<PeerImp>&&)
280  //
281  template <class UnaryFunc>
282  void
283  for_each(UnaryFunc&& f) const
284  {
286  {
287  std::lock_guard lock(mutex_);
288 
289  // Iterate over a copy of the peer list because peer
290  // destruction can invalidate iterators.
291  wp.reserve(ids_.size());
292 
293  for (auto& x : ids_)
294  wp.push_back(x.second);
295  }
296 
297  for (auto& w : wp)
298  {
299  if (auto p = w.lock())
300  f(std::move(p));
301  }
302  }
303 
304  // Called when TMManifests is received from a peer
305  void
306  onManifests(
308  std::shared_ptr<PeerImp> const& from);
309 
310  static bool
311  isPeerUpgrade(http_request_type const& request);
312 
313  template <class Body>
314  static bool
315  isPeerUpgrade(boost::beast::http::response<Body> const& response)
316  {
317  if (!is_upgrade(response))
318  return false;
319  return response.result() ==
320  boost::beast::http::status::switching_protocols;
321  }
322 
323  template <class Fields>
324  static bool
325  is_upgrade(boost::beast::http::header<true, Fields> const& req)
326  {
327  if (req.version() < 11)
328  return false;
329  if (req.method() != boost::beast::http::verb::get)
330  return false;
331  if (!boost::beast::http::token_list{req["Connection"]}.exists(
332  "upgrade"))
333  return false;
334  return true;
335  }
336 
337  template <class Fields>
338  static bool
339  is_upgrade(boost::beast::http::header<false, Fields> const& req)
340  {
341  if (req.version() < 11)
342  return false;
343  if (!boost::beast::http::token_list{req["Connection"]}.exists(
344  "upgrade"))
345  return false;
346  return true;
347  }
348 
349  static std::string
351 
352  void
353  reportTraffic(TrafficCount::category cat, bool isInbound, int bytes);
354 
355  void
357  {
359  }
360 
362  getJqTransOverflow() const override
363  {
364  return jqTransOverflow_;
365  }
366 
367  void
368  incPeerDisconnect() override
369  {
371  }
372 
374  getPeerDisconnect() const override
375  {
376  return peerDisconnects_;
377  }
378 
379  void
381  {
383  }
384 
386  getPeerDisconnectCharges() const override
387  {
389  }
390 
392  networkID() const override
393  {
394  return networkID_;
395  }
396 
398  crawlShards(bool includePublicKey, std::uint32_t relays) override;
399 
404  void
406 
416  void
418  uint256 const& key,
419  PublicKey const& validator,
420  std::set<Peer::id_t>&& peers,
421  protocol::MessageType type);
422 
425  void
427  uint256 const& key,
428  PublicKey const& validator,
429  Peer::id_t peer,
430  protocol::MessageType type);
431 
437  void
439 
441  txMetrics() const override
442  {
443  return txMetrics_.json();
444  }
445 
447  template <typename... Args>
448  void
449  addTxMetrics(Args... args)
450  {
451  if (!strand_.running_in_this_thread())
452  return post(
453  strand_,
454  std::bind(&OverlayImpl::addTxMetrics<Args...>, this, args...));
455 
456  txMetrics_.addMetrics(args...);
457  }
458 
459 private:
460  void
461  squelch(
462  PublicKey const& validator,
463  Peer::id_t const id,
464  std::uint32_t squelchDuration) const override;
465 
466  void
467  unsquelch(PublicKey const& validator, Peer::id_t id) const override;
468 
472  http_request_type const& request,
473  address_type remote_address);
474 
478  http_request_type const& request,
479  address_type remote_address,
480  std::string msg);
481 
487  bool
488  processCrawl(http_request_type const& req, Handoff& handoff);
489 
497  bool
498  processValidatorList(http_request_type const& req, Handoff& handoff);
499 
505  bool
506  processHealth(http_request_type const& req, Handoff& handoff);
507 
512  bool
513  processRequest(http_request_type const& req, Handoff& handoff);
514 
520  getOverlayInfo();
521 
527  getServerInfo();
528 
534  getServerCounts();
535 
541  getUnlInfo();
542 
543  //--------------------------------------------------------------------------
544 
545  //
546  // PropertyStream
547  //
548 
549  void
550  onWrite(beast::PropertyStream::Map& stream) override;
551 
552  //--------------------------------------------------------------------------
553 
554  void
555  remove(Child& child);
556 
557  void
558  stopChildren();
559 
560  void
561  autoConnect();
562 
563  void
564  sendEndpoints();
565 
567  void
568  sendTxQueue();
569 
572  void
573  deleteIdlePeers();
574 
575 private:
577  {
579  char const* name,
580  beast::insight::Collector::ptr const& collector)
581  : bytesIn(collector->make_gauge(name, "Bytes_In"))
582  , bytesOut(collector->make_gauge(name, "Bytes_Out"))
583  , messagesIn(collector->make_gauge(name, "Messages_In"))
584  , messagesOut(collector->make_gauge(name, "Messages_Out"))
585  {
586  }
591  };
592 
593  struct Stats
594  {
595  template <class Handler>
597  Handler const& handler,
598  beast::insight::Collector::ptr const& collector,
599  std::vector<TrafficGauges>&& trafficGauges_)
600  : peerDisconnects(
601  collector->make_gauge("Overlay", "Peer_Disconnects"))
602  , trafficGauges(std::move(trafficGauges_))
603  , hook(collector->make_hook(handler))
604  {
605  }
606 
610  };
611 
614 
615 private:
616  void
618  {
619  auto counts = m_traffic.getCounts();
621  assert(counts.size() == m_stats.trafficGauges.size());
622 
623  for (std::size_t i = 0; i < counts.size(); ++i)
624  {
625  m_stats.trafficGauges[i].bytesIn = counts[i].bytesIn;
626  m_stats.trafficGauges[i].bytesOut = counts[i].bytesOut;
627  m_stats.trafficGauges[i].messagesIn = counts[i].messagesIn;
628  m_stats.trafficGauges[i].messagesOut = counts[i].messagesOut;
629  }
631  }
632 };
633 
634 } // namespace ripple
635 
636 #endif
ripple::OverlayImpl::OverlayImpl
OverlayImpl(Application &app, Setup const &setup, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_service &io_service, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.cpp:117
beast::PropertyStream::Source::name
std::string const & name() const
Returns the name of this source.
Definition: beast_PropertyStream.cpp:190
ripple::OverlayImpl::m_statsMutex
std::mutex m_statsMutex
Definition: OverlayImpl.h:613
ripple::OverlayImpl::Stats::hook
beast::insight::Hook hook
Definition: OverlayImpl.h:609
ripple::Application
Definition: Application.h:115
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:885
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:108
std::chrono::steady_clock
ripple::OverlayImpl::address_type
boost::asio::ip::address address_type
Definition: OverlayImpl.h:78
ripple::reduce_relay::SquelchHandler
Abstract class.
Definition: overlay/Slot.h:71
ripple::TrafficCount::getCounts
auto const & getCounts() const
An up-to-date copy of all the counters.
Definition: TrafficCount.h:196
std::bind
T bind(T... args)
ripple::OverlayImpl::Timer::timer_
boost::asio::basic_waitable_timer< clock_type > timer_
Definition: OverlayImpl.h:84
std::string
STL class.
std::shared_ptr< Message >
ripple::TrafficCount
Definition: TrafficCount.h:32
beast::PropertyStream::Map
Definition: PropertyStream.h:236
ripple::OverlayImpl::peerDisconnectsCharges_
std::atomic< uint64_t > peerDisconnectsCharges_
Definition: OverlayImpl.h:120
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:617
ripple::OverlayImpl::Child::overlay_
OverlayImpl & overlay_
Definition: OverlayImpl.h:64
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
Definition: OverlayImpl.h:325
ripple::OverlayImpl::ids_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Definition: OverlayImpl.h:114
ripple::OverlayImpl::getJqTransOverflow
std::uint64_t getJqTransOverflow() const override
Definition: OverlayImpl.h:362
std::vector::reserve
T reserve(T... args)
ripple::OverlayImpl::updateSlotAndSquelch
void updateSlotAndSquelch(uint256 const &key, PublicKey const &validator, std::set< Peer::id_t > &&peers, protocol::MessageType type)
Updates message count for validator/peer.
Definition: OverlayImpl.cpp:1484
ripple::OverlayImpl::autoConnect
void autoConnect()
Definition: OverlayImpl.cpp:1410
ripple::OverlayImpl::endOfPeerChain
void endOfPeerChain(std::uint32_t id)
Called when the reply from the last peer in a peer chain is received.
Definition: OverlayImpl.cpp:774
ripple::OverlayImpl::stop
void stop() override
Definition: OverlayImpl.cpp:552
ripple::OverlayImpl::csIDs_
std::set< std::uint32_t > csIDs_
Definition: OverlayImpl.h:126
ripple::OverlayImpl::m_resolver
Resolver & m_resolver
Definition: OverlayImpl.h:115
ripple::OverlayImpl::mutex_
std::recursive_mutex mutex_
Definition: OverlayImpl.h:103
ripple::OverlayImpl::getPeerDisconnect
std::uint64_t getPeerDisconnect() const override
Definition: OverlayImpl.h:374
ripple::OverlayImpl::Timer::on_timer
void on_timer(error_code ec)
Definition: OverlayImpl.cpp:92
std::vector
STL class.
ripple::OverlayImpl::next_id_
std::atomic< Peer::id_t > next_id_
Definition: OverlayImpl.h:116
ripple::Overlay::PeerSequence
std::vector< std::shared_ptr< Peer > > PeerSequence
Definition: Overlay.h:79
ripple::OverlayImpl::makePrefix
static std::string makePrefix(std::uint32_t id)
Definition: OverlayImpl.cpp:335
ripple::OverlayImpl::onHandoff
Handoff onHandoff(std::unique_ptr< stream_type > &&bundle, http_request_type &&request, endpoint_type remote_endpoint) override
Conditionally accept an incoming HTTP request.
Definition: OverlayImpl.cpp:163
ripple::OverlayImpl::incPeerDisconnectCharges
void incPeerDisconnectCharges() override
Definition: OverlayImpl.h:380
ripple::OverlayImpl::csCV_
std::condition_variable csCV_
Definition: OverlayImpl.h:124
std::recursive_mutex
STL class.
ripple::OverlayImpl::strand_
boost::asio::io_service::strand strand_
Definition: OverlayImpl.h:102
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:857
std::lock_guard
STL class.
ripple::OverlayImpl::stopChildren
void stopChildren()
Definition: OverlayImpl.cpp:1378
ripple::OverlayImpl::TrafficGauges::TrafficGauges
TrafficGauges(char const *name, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.h:578
ripple::OverlayImpl::broadcast
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1224
ripple::OverlayImpl::connect
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Definition: OverlayImpl.cpp:390
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:922
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:178
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:117
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< false, Fields > const &req)
Definition: OverlayImpl.h:339
ripple::OverlayImpl::incJqTransOverflow
void incJqTransOverflow() override
Increment and retrieve counter for transaction job queue overflows.
Definition: OverlayImpl.h:356
ripple::OverlayImpl::networkID_
std::optional< std::uint32_t > networkID_
Definition: OverlayImpl.h:128
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:970
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:112
ripple::OverlayImpl::Stats::peerDisconnects
beast::insight::Gauge peerDisconnects
Definition: OverlayImpl.h:607
ripple::OverlayImpl::processHealth
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Definition: OverlayImpl.cpp:1038
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:107
std::condition_variable_any
ripple::OverlayImpl::start
void start() override
Definition: OverlayImpl.cpp:471
ripple::OverlayImpl::cond_
std::condition_variable_any cond_
Definition: OverlayImpl.h:104
ripple::OverlayImpl::sendTxQueue
void sendTxQueue()
Send once a second transactions' hashes aggregated by peers.
Definition: OverlayImpl.cpp:1436
ripple::TrafficCount::category
category
Definition: TrafficCount.h:67
std::vector::push_back
T push_back(T... args)
ripple::OverlayImpl::peerFinder
PeerFinder::Manager & peerFinder()
Definition: OverlayImpl.h:166
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:75
ripple::OverlayImpl::size
std::size_t size() const override
The number of active peers on the network Active peers are only those peers that have completed the h...
Definition: OverlayImpl.cpp:788
ripple::OverlayImpl::checkTracking
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
Definition: OverlayImpl.cpp:1190
ripple::OverlayImpl::operator=
OverlayImpl & operator=(OverlayImpl const &)=delete
ripple::metrics::TxMetrics::json
Json::Value json() const
Get json representation of the metrics.
Definition: TxMetrics.cpp:117
ripple::OverlayImpl::csMutex_
std::mutex csMutex_
Definition: OverlayImpl.h:123
ripple::OverlayImpl::onManifests
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Definition: OverlayImpl.cpp:625
ripple::OverlayImpl::manifestMessage_
std::shared_ptr< Message > manifestMessage_
Definition: OverlayImpl.h:136
ripple::OverlayImpl::resourceManager
Resource::Manager & resourceManager()
Definition: OverlayImpl.h:172
ripple::OverlayImpl::socket_type
boost::asio::ip::tcp::socket socket_type
Definition: OverlayImpl.h:77
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::OverlayImpl::getPeerDisconnectCharges
std::uint64_t getPeerDisconnectCharges() const override
Definition: OverlayImpl.h:386
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:801
ripple::OverlayImpl::Stats::trafficGauges
std::vector< TrafficGauges > trafficGauges
Definition: OverlayImpl.h:608
chrono
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:100
ripple::ServerHandlerImp
Definition: ServerHandlerImp.h:47
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::slots_
reduce_relay::Slots< UptimeClock > slots_
Definition: OverlayImpl.h:130
ripple::metrics::TxMetrics
Run transaction reduce-relay feature related metrics.
Definition: TxMetrics.h:88
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:612
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:891
std::enable_shared_from_this
ripple::reduce_relay::Slots
Slots is a container for validator's Slot and handles Slot update when a message is received from a v...
Definition: overlay/Slot.h:46
cstdint
ripple::OverlayImpl::app_
Application & app_
Definition: OverlayImpl.h:99
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:111
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:109
std::uint32_t
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:576
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:58
ripple::OverlayImpl::txMetrics
Json::Value txMetrics() const override
Returns tx reduce-relay metrics.
Definition: OverlayImpl.h:441
atomic
ripple::OverlayImpl::TrafficGauges::bytesIn
beast::insight::Gauge bytesIn
Definition: OverlayImpl.h:587
ripple::OverlayImpl::getActivePeers
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1144
ripple::OverlayImpl::Timer::async_wait
void async_wait()
Definition: OverlayImpl.cpp:84
memory
ripple::OverlayImpl::TrafficGauges::messagesIn
beast::insight::Gauge messagesIn
Definition: OverlayImpl.h:589
ripple::OverlayImpl::deleteIdlePeers
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
Definition: OverlayImpl.cpp:1526
beast::insight::Gauge
A metric for measuring an integral value.
Definition: Gauge.h:39
std::weak_ptr
STL class.
ripple::OverlayImpl::processRequest
bool processRequest(http_request_type const &req, Handoff &handoff)
Handles non-peer protocol requests.
Definition: OverlayImpl.cpp:1136
ripple::OverlayImpl::manifestListSeq_
std::optional< std::uint32_t > manifestListSeq_
Definition: OverlayImpl.h:138
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
ripple::OverlayImpl::networkID
std::optional< std::uint32_t > networkID() const override
Returns the ID of the network this server is configured for, if any.
Definition: OverlayImpl.h:392
ripple::OverlayImpl::deletePeer
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Definition: OverlayImpl.cpp:1517
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:62
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:110
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::OverlayImpl::relay
std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator) override
Relay a proposal.
Definition: OverlayImpl.cpp:1231
ripple::metrics::TxMetrics::addMetrics
void addMetrics(protocol::MessageType type, std::uint32_t val)
Add protocol message metrics.
Definition: TxMetrics.cpp:30
ripple::OverlayImpl::getManifestsMessage
std::shared_ptr< Message > getManifestsMessage()
Definition: OverlayImpl.cpp:1276
ripple::OverlayImpl::crawlShards
Json::Value crawlShards(bool includePublicKey, std::uint32_t relays) override
Returns information reported to the crawl shard RPC command.
Definition: OverlayImpl.cpp:687
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:462
ripple::Overlay
Manages the set of connected peers.
Definition: Overlay.h:51
std
STL namespace.
cassert
ripple::OverlayImpl::activate
void activate(std::shared_ptr< PeerImp > const &peer)
Called when a peer has connected successfully This is called after the peer handshake has been comple...
Definition: OverlayImpl.cpp:594
ripple::OverlayImpl::Timer
Definition: OverlayImpl.h:82
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:618
condition_variable
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:106
ripple::OverlayImpl::Timer::stopping_
bool stopping_
Definition: OverlayImpl.h:85
ripple::OverlayImpl::work_
std::optional< boost::asio::io_service::work > work_
Definition: OverlayImpl.h:101
ripple::OverlayImpl::Timer::Timer
Timer(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:69
ripple::OverlayImpl::Child::stop
virtual void stop()=0
ripple::OverlayImpl::squelch
void squelch(PublicKey const &validator, Peer::id_t const id, std::uint32_t squelchDuration) const override
Squelch handler.
Definition: OverlayImpl.cpp:1471
ripple::Handoff
Used to indicate the result of a server connection handoff.
Definition: Handoff.h:37
ripple::OverlayImpl::Timer::stop
void stop() override
Definition: OverlayImpl.cpp:75
ripple::OverlayImpl::findPeerByPublicKey
std::shared_ptr< Peer > findPeerByPublicKey(PublicKey const &pubKey) override
Returns the peer with the matching public key, or null.
Definition: OverlayImpl.cpp:1209
optional
mutex
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(boost::beast::http::response< Body > const &response)
Definition: OverlayImpl.h:315
ripple::OverlayImpl::TrafficGauges::bytesOut
beast::insight::Gauge bytesOut
Definition: OverlayImpl.h:588
ripple::OverlayImpl::txMetrics_
metrics::TxMetrics txMetrics_
Definition: OverlayImpl.h:133
std::size_t
ripple::OverlayImpl::makeRedirectResponse
std::shared_ptr< Writer > makeRedirectResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address)
Definition: OverlayImpl.cpp:343
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
ripple::OverlayImpl::incPeerDisconnect
void incPeerDisconnect() override
Increment and retrieve counters for total peer disconnects, and disconnects we initiate for excessive...
Definition: OverlayImpl.h:368
ripple::OverlayImpl::addTxMetrics
void addTxMetrics(Args... args)
Add tx reduce-relay metrics.
Definition: OverlayImpl.h:449
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:105
ripple::OverlayImpl::jqTransOverflow_
std::atomic< uint64_t > jqTransOverflow_
Definition: OverlayImpl.h:118
ripple::OverlayImpl
Definition: OverlayImpl.h:58
ripple::OverlayImpl::findPeerByShortID
std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id) const override
Returns the peer with the matching short id, or null.
Definition: OverlayImpl.cpp:1197
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:678
ripple::OverlayImpl::Stats::Stats
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector, std::vector< TrafficGauges > &&trafficGauges_)
Definition: OverlayImpl.h:596
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:61
ripple::OverlayImpl::peerDisconnects_
std::atomic< uint64_t > peerDisconnects_
Definition: OverlayImpl.h:119
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handshake.h:47
std::unique_ptr
STL class.
ripple::OverlayImpl::makeErrorResponse
std::shared_ptr< Writer > makeErrorResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address, std::string msg)
Definition: OverlayImpl.cpp:370
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:113
ripple::OverlayImpl::TrafficGauges::messagesOut
beast::insight::Gauge messagesOut
Definition: OverlayImpl.h:590
unordered_map
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(http_request_type const &request)
Definition: OverlayImpl.cpp:326
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:428
beast::insight::Hook
A reference to a handler for performing polled collection.
Definition: Hook.h:31
ripple::OverlayImpl::error_code
boost::system::error_code error_code
Definition: OverlayImpl.h:80
ripple::OverlayImpl::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: OverlayImpl.cpp:569
std::set< std::uint32_t >
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:215
ripple::OverlayImpl::manifestLock_
std::mutex manifestLock_
Definition: OverlayImpl.h:140
ripple::OverlayImpl::sendEndpoints
void sendEndpoints()
Definition: OverlayImpl.cpp:1418
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f) const
Definition: OverlayImpl.h:283
ripple::PeerFinder::Manager
Maintains a set of IP addresses used for getting into the network.
Definition: PeerfinderManager.h:138
ripple::OverlayImpl::unsquelch
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Definition: OverlayImpl.cpp:1459
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::OverlayImpl::limit
int limit() override
Returns the maximum number of peers we are configured to allow.
Definition: OverlayImpl.cpp:795
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:933
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:79
ripple::OverlayImpl::Stats
Definition: OverlayImpl.h:593