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/peerfinder/PeerfinderManager.h>
34 #include <ripple/resource/ResourceManager.h>
35 #include <ripple/rpc/ServerHandler.h>
36 #include <ripple/server/Handoff.h>
37 #include <boost/asio/basic_waitable_timer.hpp>
38 #include <boost/asio/ip/tcp.hpp>
39 #include <boost/asio/ssl/context.hpp>
40 #include <boost/asio/strand.hpp>
41 #include <boost/container/flat_map.hpp>
42 #include <atomic>
43 #include <cassert>
44 #include <chrono>
45 #include <condition_variable>
46 #include <cstdint>
47 #include <memory>
48 #include <mutex>
49 #include <optional>
50 #include <unordered_map>
51 
52 namespace ripple {
53 
54 class PeerImp;
55 class BasicConfig;
56 
58 {
59 public:
60  class Child
61  {
62  protected:
64 
65  explicit Child(OverlayImpl& overlay);
66 
67  virtual ~Child();
68 
69  public:
70  virtual void
71  stop() = 0;
72  };
73 
74 private:
76  using socket_type = boost::asio::ip::tcp::socket;
77  using address_type = boost::asio::ip::address;
78  using endpoint_type = boost::asio::ip::tcp::endpoint;
79  using error_code = boost::system::error_code;
80 
82  {
83  boost::asio::basic_waitable_timer<clock_type> timer_;
84  bool stopping_{false};
85 
86  explicit Timer(OverlayImpl& overlay);
87 
88  void
89  stop() override;
90 
91  void
92  async_wait();
93 
94  void
95  on_timer(error_code ec);
96  };
97 
99  boost::asio::io_service& io_service_;
101  boost::asio::io_service::strand strand_;
102  mutable std::recursive_mutex mutex_; // VFALCO use std::mutex
105  boost::container::flat_map<Child*, std::weak_ptr<Child>> list_;
106  Setup setup_;
120 
121  // 'cs' = crawl shards
124  // Peer IDs expecting to receive a last link notification
126 
128 
130 
131  // A message with the list of manifests we send to peers
133  // Used to track whether we need to update the cached list of manifests
135  // Protects the message and the sequence list of manifests
137 
138  //--------------------------------------------------------------------------
139 
140 public:
141  OverlayImpl(
142  Application& app,
143  Setup const& setup,
144  ServerHandler& serverHandler,
146  Resolver& resolver,
147  boost::asio::io_service& io_service,
148  BasicConfig const& config,
149  beast::insight::Collector::ptr const& collector);
150 
151  OverlayImpl(OverlayImpl const&) = delete;
152  OverlayImpl&
153  operator=(OverlayImpl const&) = delete;
154 
155  void
156  start() override;
157 
158  void
159  stop() override;
160 
163  {
164  return *m_peerFinder;
165  }
166 
169  {
170  return m_resourceManager;
171  }
172 
173  Setup const&
174  setup() const
175  {
176  return setup_;
177  }
178 
179  Handoff
180  onHandoff(
182  http_request_type&& request,
183  endpoint_type remote_endpoint) override;
184 
185  void
186  connect(beast::IP::Endpoint const& remote_endpoint) override;
187 
188  int
189  limit() override;
190 
192  size() const override;
193 
195  json() override;
196 
198  getActivePeers() const override;
199 
200  void checkTracking(std::uint32_t) override;
201 
203  findPeerByShortID(Peer::id_t const& id) const override;
204 
206  findPeerByPublicKey(PublicKey const& pubKey) override;
207 
208  void
209  broadcast(protocol::TMProposeSet& m) override;
210 
211  void
212  broadcast(protocol::TMValidation& m) override;
213 
215  relay(
216  protocol::TMProposeSet& m,
217  uint256 const& uid,
218  PublicKey const& validator) override;
219 
221  relay(
222  protocol::TMValidation& m,
223  uint256 const& uid,
224  PublicKey const& validator) override;
225 
228 
229  //--------------------------------------------------------------------------
230  //
231  // OverlayImpl
232  //
233 
234  void
236 
237  void
239 
245  void
246  activate(std::shared_ptr<PeerImp> const& peer);
247 
248  // Called when an active peer is destroyed.
249  void
251 
252  // UnaryFunc will be called as
253  // void(std::shared_ptr<PeerImp>&&)
254  //
255  template <class UnaryFunc>
256  void
257  for_each(UnaryFunc&& f) const
258  {
260  {
261  std::lock_guard lock(mutex_);
262 
263  // Iterate over a copy of the peer list because peer
264  // destruction can invalidate iterators.
265  wp.reserve(ids_.size());
266 
267  for (auto& x : ids_)
268  wp.push_back(x.second);
269  }
270 
271  for (auto& w : wp)
272  {
273  if (auto p = w.lock())
274  f(std::move(p));
275  }
276  }
277 
278  // Called when TMManifests is received from a peer
279  void
280  onManifests(
282  std::shared_ptr<PeerImp> const& from);
283 
284  static bool
285  isPeerUpgrade(http_request_type const& request);
286 
287  template <class Body>
288  static bool
289  isPeerUpgrade(boost::beast::http::response<Body> const& response)
290  {
291  if (!is_upgrade(response))
292  return false;
293  return response.result() ==
294  boost::beast::http::status::switching_protocols;
295  }
296 
297  template <class Fields>
298  static bool
299  is_upgrade(boost::beast::http::header<true, Fields> const& req)
300  {
301  if (req.version() < 11)
302  return false;
303  if (req.method() != boost::beast::http::verb::get)
304  return false;
305  if (!boost::beast::http::token_list{req["Connection"]}.exists(
306  "upgrade"))
307  return false;
308  return true;
309  }
310 
311  template <class Fields>
312  static bool
313  is_upgrade(boost::beast::http::header<false, Fields> const& req)
314  {
315  if (req.version() < 11)
316  return false;
317  if (!boost::beast::http::token_list{req["Connection"]}.exists(
318  "upgrade"))
319  return false;
320  return true;
321  }
322 
323  static std::string
325 
326  void
327  reportTraffic(TrafficCount::category cat, bool isInbound, int bytes);
328 
329  void
331  {
333  }
334 
336  getJqTransOverflow() const override
337  {
338  return jqTransOverflow_;
339  }
340 
341  void
342  incPeerDisconnect() override
343  {
345  }
346 
348  getPeerDisconnect() const override
349  {
350  return peerDisconnects_;
351  }
352 
353  void
355  {
357  }
358 
360  getPeerDisconnectCharges() const override
361  {
363  }
364 
366  networkID() const override
367  {
368  return networkID_;
369  }
370 
372  crawlShards(bool includePublicKey, std::uint32_t relays) override;
373 
378  void
380 
390  void
392  uint256 const& key,
393  PublicKey const& validator,
394  std::set<Peer::id_t>&& peers,
395  protocol::MessageType type);
396 
399  void
401  uint256 const& key,
402  PublicKey const& validator,
403  Peer::id_t peer,
404  protocol::MessageType type);
405 
411  void
413 
414 private:
415  void
416  squelch(
417  PublicKey const& validator,
418  Peer::id_t const id,
419  std::uint32_t squelchDuration) const override;
420 
421  void
422  unsquelch(PublicKey const& validator, Peer::id_t id) const override;
423 
427  http_request_type const& request,
428  address_type remote_address);
429 
433  http_request_type const& request,
434  address_type remote_address,
435  std::string msg);
436 
442  bool
443  processCrawl(http_request_type const& req, Handoff& handoff);
444 
452  bool
453  processValidatorList(http_request_type const& req, Handoff& handoff);
454 
460  bool
461  processHealth(http_request_type const& req, Handoff& handoff);
462 
467  bool
468  processRequest(http_request_type const& req, Handoff& handoff);
469 
475  getOverlayInfo();
476 
482  getServerInfo();
483 
489  getServerCounts();
490 
496  getUnlInfo();
497 
498  //--------------------------------------------------------------------------
499 
500  //
501  // PropertyStream
502  //
503 
504  void
505  onWrite(beast::PropertyStream::Map& stream) override;
506 
507  //--------------------------------------------------------------------------
508 
509  void
510  remove(Child& child);
511 
512  void
513  stopChildren();
514 
515  void
516  autoConnect();
517 
518  void
519  sendEndpoints();
520 
523  void
524  deleteIdlePeers();
525 
526 private:
528  {
530  char const* name,
531  beast::insight::Collector::ptr const& collector)
532  : bytesIn(collector->make_gauge(name, "Bytes_In"))
533  , bytesOut(collector->make_gauge(name, "Bytes_Out"))
534  , messagesIn(collector->make_gauge(name, "Messages_In"))
535  , messagesOut(collector->make_gauge(name, "Messages_Out"))
536  {
537  }
542  };
543 
544  struct Stats
545  {
546  template <class Handler>
548  Handler const& handler,
549  beast::insight::Collector::ptr const& collector,
550  std::vector<TrafficGauges>&& trafficGauges_)
551  : peerDisconnects(
552  collector->make_gauge("Overlay", "Peer_Disconnects"))
553  , trafficGauges(std::move(trafficGauges_))
554  , hook(collector->make_hook(handler))
555  {
556  }
557 
561  };
562 
565 
566 private:
567  void
569  {
570  auto counts = m_traffic.getCounts();
572  assert(counts.size() == m_stats.trafficGauges.size());
573 
574  for (std::size_t i = 0; i < counts.size(); ++i)
575  {
576  m_stats.trafficGauges[i].bytesIn = counts[i].bytesIn;
577  m_stats.trafficGauges[i].bytesOut = counts[i].bytesOut;
578  m_stats.trafficGauges[i].messagesIn = counts[i].messagesIn;
579  m_stats.trafficGauges[i].messagesOut = counts[i].messagesOut;
580  }
582  }
583 };
584 
585 } // namespace ripple
586 
587 #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:114
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:564
ripple::OverlayImpl::Stats::hook
beast::insight::Hook hook
Definition: OverlayImpl.h:560
ripple::Application
Definition: Application.h:103
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:882
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:107
std::chrono::steady_clock
ripple::OverlayImpl::address_type
boost::asio::ip::address address_type
Definition: OverlayImpl.h:77
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:187
ripple::OverlayImpl::Timer::timer_
boost::asio::basic_waitable_timer< clock_type > timer_
Definition: OverlayImpl.h:83
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:119
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:568
ripple::OverlayImpl::Child::overlay_
OverlayImpl & overlay_
Definition: OverlayImpl.h:63
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
Definition: OverlayImpl.h:299
ripple::OverlayImpl::ids_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Definition: OverlayImpl.h:113
ripple::OverlayImpl::getJqTransOverflow
std::uint64_t getJqTransOverflow() const override
Definition: OverlayImpl.h:336
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:1376
ripple::OverlayImpl::autoConnect
void autoConnect()
Definition: OverlayImpl.cpp:1311
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:771
ripple::OverlayImpl::stop
void stop() override
Definition: OverlayImpl.cpp:549
ripple::OverlayImpl::csIDs_
std::set< std::uint32_t > csIDs_
Definition: OverlayImpl.h:125
ripple::OverlayImpl::m_resolver
Resolver & m_resolver
Definition: OverlayImpl.h:114
ripple::OverlayImpl::mutex_
std::recursive_mutex mutex_
Definition: OverlayImpl.h:102
ripple::OverlayImpl::getPeerDisconnect
std::uint64_t getPeerDisconnect() const override
Definition: OverlayImpl.h:348
ripple::OverlayImpl::Timer::on_timer
void on_timer(error_code ec)
Definition: OverlayImpl.cpp:91
std::vector
STL class.
ripple::OverlayImpl::next_id_
std::atomic< Peer::id_t > next_id_
Definition: OverlayImpl.h:115
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:332
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:160
ripple::OverlayImpl::incPeerDisconnectCharges
void incPeerDisconnectCharges() override
Definition: OverlayImpl.h:354
ripple::OverlayImpl::csCV_
std::condition_variable csCV_
Definition: OverlayImpl.h:123
std::recursive_mutex
STL class.
ripple::OverlayImpl::strand_
boost::asio::io_service::strand strand_
Definition: OverlayImpl.h:101
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:854
std::lock_guard
STL class.
ripple::OverlayImpl::stopChildren
void stopChildren()
Definition: OverlayImpl.cpp:1279
ripple::OverlayImpl::TrafficGauges::TrafficGauges
TrafficGauges(char const *name, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.h:529
ripple::OverlayImpl::broadcast
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1186
ripple::OverlayImpl::connect
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Definition: OverlayImpl.cpp:387
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:919
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:174
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:116
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< false, Fields > const &req)
Definition: OverlayImpl.h:313
ripple::OverlayImpl::incJqTransOverflow
void incJqTransOverflow() override
Increment and retrieve counter for transaction job queue overflows.
Definition: OverlayImpl.h:330
ripple::OverlayImpl::networkID_
std::optional< std::uint32_t > networkID_
Definition: OverlayImpl.h:127
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:967
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:111
ripple::OverlayImpl::Stats::peerDisconnects
beast::insight::Gauge peerDisconnects
Definition: OverlayImpl.h:558
ripple::OverlayImpl::processHealth
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Definition: OverlayImpl.cpp:1035
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:106
std::condition_variable_any
ripple::OverlayImpl::start
void start() override
Definition: OverlayImpl.cpp:468
ripple::OverlayImpl::cond_
std::condition_variable_any cond_
Definition: OverlayImpl.h:103
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:162
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:74
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:785
ripple::OverlayImpl::checkTracking
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
Definition: OverlayImpl.cpp:1152
ripple::OverlayImpl::operator=
OverlayImpl & operator=(OverlayImpl const &)=delete
ripple::OverlayImpl::csMutex_
std::mutex csMutex_
Definition: OverlayImpl.h:122
ripple::OverlayImpl::onManifests
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Definition: OverlayImpl.cpp:622
ripple::OverlayImpl::manifestMessage_
std::shared_ptr< Message > manifestMessage_
Definition: OverlayImpl.h:132
ripple::OverlayImpl::resourceManager
Resource::Manager & resourceManager()
Definition: OverlayImpl.h:168
ripple::OverlayImpl::socket_type
boost::asio::ip::tcp::socket socket_type
Definition: OverlayImpl.h:76
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::OverlayImpl::getPeerDisconnectCharges
std::uint64_t getPeerDisconnectCharges() const override
Definition: OverlayImpl.h:360
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:798
ripple::OverlayImpl::Stats::trafficGauges
std::vector< TrafficGauges > trafficGauges
Definition: OverlayImpl.h:559
chrono
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:99
ripple::ServerHandlerImp
Definition: ServerHandlerImp.h:47
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::slots_
reduce_relay::Slots< UptimeClock > slots_
Definition: OverlayImpl.h:129
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:563
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:888
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:98
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:110
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:108
std::uint32_t
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:527
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:57
atomic
ripple::OverlayImpl::TrafficGauges::bytesIn
beast::insight::Gauge bytesIn
Definition: OverlayImpl.h:538
ripple::OverlayImpl::getActivePeers
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1139
ripple::OverlayImpl::Timer::async_wait
void async_wait()
Definition: OverlayImpl.cpp:83
memory
ripple::OverlayImpl::TrafficGauges::messagesIn
beast::insight::Gauge messagesIn
Definition: OverlayImpl.h:540
ripple::OverlayImpl::deleteIdlePeers
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
Definition: OverlayImpl.cpp:1418
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:1131
ripple::OverlayImpl::manifestListSeq_
std::optional< std::uint32_t > manifestListSeq_
Definition: OverlayImpl.h:134
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:366
ripple::OverlayImpl::deletePeer
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Definition: OverlayImpl.cpp:1409
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:61
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:109
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:1193
ripple::OverlayImpl::getManifestsMessage
std::shared_ptr< Message > getManifestsMessage()
Definition: OverlayImpl.cpp:1238
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:684
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:459
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:591
ripple::OverlayImpl::Timer
Definition: OverlayImpl.h:81
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:615
condition_variable
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:105
ripple::OverlayImpl::Timer::stopping_
bool stopping_
Definition: OverlayImpl.h:84
ripple::OverlayImpl::work_
std::optional< boost::asio::io_service::work > work_
Definition: OverlayImpl.h:100
ripple::OverlayImpl::Timer::Timer
Timer(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:68
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:1363
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:74
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:1171
optional
mutex
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(boost::beast::http::response< Body > const &response)
Definition: OverlayImpl.h:289
ripple::OverlayImpl::TrafficGauges::bytesOut
beast::insight::Gauge bytesOut
Definition: OverlayImpl.h:539
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:340
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:342
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:104
ripple::OverlayImpl::jqTransOverflow_
std::atomic< uint64_t > jqTransOverflow_
Definition: OverlayImpl.h:117
ripple::OverlayImpl
Definition: OverlayImpl.h:57
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:1159
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:675
ripple::OverlayImpl::Stats::Stats
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector, std::vector< TrafficGauges > &&trafficGauges_)
Definition: OverlayImpl.h:547
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:60
ripple::OverlayImpl::peerDisconnects_
std::atomic< uint64_t > peerDisconnects_
Definition: OverlayImpl.h:118
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:367
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:112
ripple::OverlayImpl::TrafficGauges::messagesOut
beast::insight::Gauge messagesOut
Definition: OverlayImpl.h:541
unordered_map
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(http_request_type const &request)
Definition: OverlayImpl.cpp:323
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:425
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:79
ripple::OverlayImpl::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: OverlayImpl.cpp:566
std::set< std::uint32_t >
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:215
ripple::OverlayImpl::manifestLock_
std::mutex manifestLock_
Definition: OverlayImpl.h:136
ripple::OverlayImpl::sendEndpoints
void sendEndpoints()
Definition: OverlayImpl.cpp:1319
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f) const
Definition: OverlayImpl.h:257
ripple::PeerFinder::Manager
Maintains a set of IP addresses used for getting into the network.
Definition: PeerfinderManager.h:135
ripple::OverlayImpl::unsquelch
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Definition: OverlayImpl.cpp:1351
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:792
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:930
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:78
ripple::OverlayImpl::Stats
Definition: OverlayImpl.h:544