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/Overlay.h>
29 #include <ripple/overlay/impl/Handshake.h>
30 #include <ripple/overlay/impl/TrafficCount.h>
31 #include <ripple/peerfinder/PeerfinderManager.h>
32 #include <ripple/resource/ResourceManager.h>
33 #include <ripple/rpc/ServerHandler.h>
34 #include <ripple/server/Handoff.h>
35 #include <boost/asio/basic_waitable_timer.hpp>
36 #include <boost/asio/ip/tcp.hpp>
37 #include <boost/asio/ssl/context.hpp>
38 #include <boost/asio/strand.hpp>
39 #include <boost/container/flat_map.hpp>
40 #include <boost/optional.hpp>
41 #include <atomic>
42 #include <cassert>
43 #include <chrono>
44 #include <condition_variable>
45 #include <cstdint>
46 #include <memory>
47 #include <mutex>
48 #include <unordered_map>
49 
50 namespace ripple {
51 
52 class PeerImp;
53 class BasicConfig;
54 
55 class OverlayImpl : public Overlay
56 {
57 public:
58  class Child
59  {
60  protected:
62 
63  explicit Child(OverlayImpl& overlay);
64 
65  virtual ~Child();
66 
67  public:
68  virtual void
69  stop() = 0;
70  };
71 
72 private:
74  using socket_type = boost::asio::ip::tcp::socket;
75  using address_type = boost::asio::ip::address;
76  using endpoint_type = boost::asio::ip::tcp::endpoint;
77  using error_code = boost::system::error_code;
78 
80  {
81  boost::asio::basic_waitable_timer<clock_type> timer_;
82 
83  explicit Timer(OverlayImpl& overlay);
84 
85  void
86  stop() override;
87 
88  void
89  run();
90 
91  void
92  on_timer(error_code ec);
93  };
94 
96  boost::asio::io_service& io_service_;
97  boost::optional<boost::asio::io_service::work> work_;
98  boost::asio::io_service::strand strand_;
99  mutable std::recursive_mutex mutex_; // VFALCO use std::mutex
102  boost::container::flat_map<Child*, std::weak_ptr<Child>> list_;
103  Setup setup_;
117 
118  // Last time we crawled peers for shard info. 'cs' = crawl shards
122  // Peer IDs expecting to receive a last link notification
124 
125  boost::optional<std::uint32_t> networkID_;
126 
127  //--------------------------------------------------------------------------
128 
129 public:
130  OverlayImpl(
131  Application& app,
132  Setup const& setup,
133  Stoppable& parent,
136  Resolver& resolver,
137  boost::asio::io_service& io_service,
138  BasicConfig const& config,
139  beast::insight::Collector::ptr const& collector);
140 
141  ~OverlayImpl();
142 
143  OverlayImpl(OverlayImpl const&) = delete;
144  OverlayImpl&
145  operator=(OverlayImpl const&) = delete;
146 
149  {
150  return *m_peerFinder;
151  }
152 
155  {
156  return m_resourceManager;
157  }
158 
161  {
162  return serverHandler_;
163  }
164 
165  Setup const&
166  setup() const
167  {
168  return setup_;
169  }
170 
171  Handoff
172  onHandoff(
174  http_request_type&& request,
175  endpoint_type remote_endpoint) override;
176 
177  void
178  connect(beast::IP::Endpoint const& remote_endpoint) override;
179 
180  int
181  limit() override;
182 
184  size() const override;
185 
187  json() override;
188 
190  getActivePeers() const override;
191 
192  void
193  check() override;
194 
195  void checkSanity(std::uint32_t) override;
196 
198  findPeerByShortID(Peer::id_t const& id) override;
199 
201  findPeerByPublicKey(PublicKey const& pubKey) override;
202 
203  void
204  broadcast(protocol::TMProposeSet& m) override;
205 
206  void
207  broadcast(protocol::TMValidation& m) override;
208 
209  void
210  relay(protocol::TMProposeSet& m, uint256 const& uid) override;
211 
212  void
213  relay(protocol::TMValidation& m, uint256 const& uid) override;
214 
215  //--------------------------------------------------------------------------
216  //
217  // OverlayImpl
218  //
219 
220  void
222 
223  void
225 
231  void
232  activate(std::shared_ptr<PeerImp> const& peer);
233 
234  // Called when an active peer is destroyed.
235  void
237 
238  // UnaryFunc will be called as
239  // void(std::shared_ptr<PeerImp>&&)
240  //
241  template <class UnaryFunc>
242  void
243  for_each(UnaryFunc&& f) const
244  {
246  {
247  std::lock_guard lock(mutex_);
248 
249  // Iterate over a copy of the peer list because peer
250  // destruction can invalidate iterators.
251  wp.reserve(ids_.size());
252 
253  for (auto& x : ids_)
254  wp.push_back(x.second);
255  }
256 
257  for (auto& w : wp)
258  {
259  if (auto p = w.lock())
260  f(std::move(p));
261  }
262  }
263 
264  // Called when TMManifests is received from a peer
265  void
266  onManifests(
268  std::shared_ptr<PeerImp> const& from);
269 
270  static bool
271  isPeerUpgrade(http_request_type const& request);
272 
273  template <class Body>
274  static bool
275  isPeerUpgrade(boost::beast::http::response<Body> const& response)
276  {
277  if (!is_upgrade(response))
278  return false;
279  return response.result() ==
280  boost::beast::http::status::switching_protocols;
281  }
282 
283  template <class Fields>
284  static bool
285  is_upgrade(boost::beast::http::header<true, Fields> const& req)
286  {
287  if (req.version() < 11)
288  return false;
289  if (req.method() != boost::beast::http::verb::get)
290  return false;
291  if (!boost::beast::http::token_list{req["Connection"]}.exists(
292  "upgrade"))
293  return false;
294  return true;
295  }
296 
297  template <class Fields>
298  static bool
299  is_upgrade(boost::beast::http::header<false, Fields> const& req)
300  {
301  if (req.version() < 11)
302  return false;
303  if (!boost::beast::http::token_list{req["Connection"]}.exists(
304  "upgrade"))
305  return false;
306  return true;
307  }
308 
309  static std::string
311 
312  void
313  reportTraffic(TrafficCount::category cat, bool isInbound, int bytes);
314 
315  void
317  {
319  }
320 
322  getJqTransOverflow() const override
323  {
324  return jqTransOverflow_;
325  }
326 
327  void
328  incPeerDisconnect() override
329  {
331  }
332 
334  getPeerDisconnect() const override
335  {
336  return peerDisconnects_;
337  }
338 
339  void
341  {
343  }
344 
346  getPeerDisconnectCharges() const override
347  {
349  }
350 
351  boost::optional<std::uint32_t>
352  networkID() const override
353  {
354  return networkID_;
355  }
356 
358  crawlShards(bool pubKey, std::uint32_t hops) override;
359 
364  void
366 
367 private:
371  http_request_type const& request,
372  address_type remote_address);
373 
377  http_request_type const& request,
378  address_type remote_address,
379  std::string msg);
380 
386  bool
387  processCrawl(http_request_type const& req, Handoff& handoff);
388 
396  bool
397  processValidatorList(http_request_type const& req, Handoff& handoff);
398 
404  bool
405  processHealth(http_request_type const& req, Handoff& handoff);
406 
411  bool
412  processRequest(http_request_type const& req, Handoff& handoff);
413 
419  getOverlayInfo();
420 
426  getServerInfo();
427 
433  getServerCounts();
434 
440  getUnlInfo();
441 
442  //--------------------------------------------------------------------------
443 
444  //
445  // Stoppable
446  //
447 
448  void
449  checkStopped();
450 
451  void
452  onPrepare() override;
453 
454  void
455  onStart() override;
456 
457  void
458  onStop() override;
459 
460  void
461  onChildrenStopped() override;
462 
463  //
464  // PropertyStream
465  //
466 
467  void
468  onWrite(beast::PropertyStream::Map& stream) override;
469 
470  //--------------------------------------------------------------------------
471 
472  void
473  remove(Child& child);
474 
475  void
476  stop();
477 
478  void
479  autoConnect();
480 
481  void
482  sendEndpoints();
483 
484 private:
486  {
488  char const* name,
489  beast::insight::Collector::ptr const& collector)
490  : bytesIn(collector->make_gauge(name, "Bytes_In"))
491  , bytesOut(collector->make_gauge(name, "Bytes_Out"))
492  , messagesIn(collector->make_gauge(name, "Messages_In"))
493  , messagesOut(collector->make_gauge(name, "Messages_Out"))
494  {
495  }
500  };
501 
502  struct Stats
503  {
504  template <class Handler>
506  Handler const& handler,
507  beast::insight::Collector::ptr const& collector,
508  std::vector<TrafficGauges>&& trafficGauges_)
509  : peerDisconnects(
510  collector->make_gauge("Overlay", "Peer_Disconnects"))
511  , trafficGauges(std::move(trafficGauges_))
512  , hook(collector->make_hook(handler))
513  {
514  }
515 
519  };
520 
523 
524 private:
525  void
527  {
528  auto counts = m_traffic.getCounts();
530  assert(counts.size() == m_stats.trafficGauges.size());
531 
532  for (std::size_t i = 0; i < counts.size(); ++i)
533  {
534  m_stats.trafficGauges[i].bytesIn = counts[i].bytesIn;
535  m_stats.trafficGauges[i].bytesOut = counts[i].bytesOut;
536  m_stats.trafficGauges[i].messagesIn = counts[i].messagesIn;
537  m_stats.trafficGauges[i].messagesOut = counts[i].messagesOut;
538  }
540  }
541 };
542 
543 } // namespace ripple
544 
545 #endif
beast::PropertyStream::Source::name
std::string const & name() const
Returns the name of this source.
Definition: beast_PropertyStream.cpp:190
ripple::OverlayImpl::findPeerByShortID
std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id) override
Returns the peer with the matching short id, or null.
Definition: OverlayImpl.cpp:1205
ripple::OverlayImpl::relay
void relay(protocol::TMProposeSet &m, uint256 const &uid) override
Relay a proposal.
Definition: OverlayImpl.cpp:1239
ripple::OverlayImpl::m_statsMutex
std::mutex m_statsMutex
Definition: OverlayImpl.h:522
ripple::OverlayImpl::Stats::hook
beast::insight::Hook hook
Definition: OverlayImpl.h:518
ripple::Application
Definition: Application.h:97
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:954
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:104
std::chrono::steady_clock
ripple::OverlayImpl::address_type
boost::asio::ip::address address_type
Definition: OverlayImpl.h:75
ripple::OverlayImpl::Timer::run
void run()
Definition: OverlayImpl.cpp:80
ripple::TrafficCount::getCounts
auto const & getCounts() const
An up-to-date copy of all the counters.
Definition: TrafficCount.h:179
ripple::OverlayImpl::Timer::timer_
boost::asio::basic_waitable_timer< clock_type > timer_
Definition: OverlayImpl.h:81
std::string
STL class.
std::shared_ptr< Collector >
ripple::OverlayImpl::work_
boost::optional< boost::asio::io_service::work > work_
Definition: OverlayImpl.h:97
ripple::TrafficCount
Definition: TrafficCount.h:32
beast::PropertyStream::Map
Definition: PropertyStream.h:236
ripple::OverlayImpl::peerDisconnectsCharges_
std::atomic< uint64_t > peerDisconnectsCharges_
Definition: OverlayImpl.h:116
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:526
ripple::OverlayImpl::Child::overlay_
OverlayImpl & overlay_
Definition: OverlayImpl.h:61
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
Definition: OverlayImpl.h:285
ripple::OverlayImpl::ids_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Definition: OverlayImpl.h:110
ripple::OverlayImpl::getJqTransOverflow
std::uint64_t getJqTransOverflow() const override
Definition: OverlayImpl.h:322
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handoff.h:31
std::vector::reserve
T reserve(T... args)
ripple::OverlayImpl::autoConnect
void autoConnect()
Definition: OverlayImpl.cpp:1316
ripple::OverlayImpl::csIDs_
std::set< std::uint32_t > csIDs_
Definition: OverlayImpl.h:123
ripple::OverlayImpl::m_resolver
Resolver & m_resolver
Definition: OverlayImpl.h:111
ripple::OverlayImpl::mutex_
std::recursive_mutex mutex_
Definition: OverlayImpl.h:99
ripple::OverlayImpl::getPeerDisconnect
std::uint64_t getPeerDisconnect() const override
Definition: OverlayImpl.h:334
ripple::OverlayImpl::Timer::on_timer
void on_timer(error_code ec)
Definition: OverlayImpl.cpp:88
std::vector
STL class.
ripple::OverlayImpl::next_id_
std::atomic< Peer::id_t > next_id_
Definition: OverlayImpl.h:112
ripple::Overlay::PeerSequence
std::vector< std::shared_ptr< Peer > > PeerSequence
Definition: Overlay.h:82
ripple::OverlayImpl::makePrefix
static std::string makePrefix(std::uint32_t id)
Definition: OverlayImpl.cpp:346
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:174
std::chrono::seconds
ripple::OverlayImpl::incPeerDisconnectCharges
void incPeerDisconnectCharges() override
Definition: OverlayImpl.h:340
ripple::OverlayImpl::csCV_
std::condition_variable csCV_
Definition: OverlayImpl.h:121
std::recursive_mutex
STL class.
ripple::OverlayImpl::strand_
boost::asio::io_service::strand strand_
Definition: OverlayImpl.h:98
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:926
std::lock_guard
STL class.
ripple::OverlayImpl::onStart
void onStart() override
Override called during start.
Definition: OverlayImpl.cpp:593
ripple::OverlayImpl::TrafficGauges::TrafficGauges
TrafficGauges(char const *name, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.h:487
ripple::OverlayImpl::broadcast
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1232
ripple::OverlayImpl::connect
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Definition: OverlayImpl.cpp:397
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:991
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:166
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:113
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< false, Fields > const &req)
Definition: OverlayImpl.h:299
ripple::OverlayImpl::incJqTransOverflow
void incJqTransOverflow() override
Increment and retrieve counter for transaction job queue overflows.
Definition: OverlayImpl.h:316
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:1039
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:108
ripple::OverlayImpl::Stats::peerDisconnects
beast::insight::Gauge peerDisconnects
Definition: OverlayImpl.h:516
ripple::OverlayImpl::processHealth
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Definition: OverlayImpl.cpp:1085
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:103
std::condition_variable_any
ripple::OverlayImpl::onChildrenStopped
void onChildrenStopped() override
Override called when all children have stopped.
Definition: OverlayImpl.cpp:609
ripple::OverlayImpl::cond_
std::condition_variable_any cond_
Definition: OverlayImpl.h:100
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:148
ripple::base_uint< 256 >
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:865
ripple::OverlayImpl::operator=
OverlayImpl & operator=(OverlayImpl const &)=delete
ripple::OverlayImpl::csMutex_
std::mutex csMutex_
Definition: OverlayImpl.h:120
ripple::OverlayImpl::onManifests
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Definition: OverlayImpl.cpp:678
ripple::Stoppable
Provides an interface for starting and stopping.
Definition: Stoppable.h:200
ripple::OverlayImpl::resourceManager
Resource::Manager & resourceManager()
Definition: OverlayImpl.h:154
ripple::OverlayImpl::socket_type
boost::asio::ip::tcp::socket socket_type
Definition: OverlayImpl.h:74
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::OverlayImpl::networkID_
boost::optional< std::uint32_t > networkID_
Definition: OverlayImpl.h:125
ripple::OverlayImpl::getPeerDisconnectCharges
std::uint64_t getPeerDisconnectCharges() const override
Definition: OverlayImpl.h:346
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:878
ripple::OverlayImpl::Stats::trafficGauges
std::vector< TrafficGauges > trafficGauges
Definition: OverlayImpl.h:517
chrono
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:96
ripple::ServerHandlerImp
Definition: ServerHandlerImp.h:46
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:521
ripple::OverlayImpl::serverHandler
ServerHandler & serverHandler()
Definition: OverlayImpl.h:160
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:960
ripple::OverlayImpl::checkStopped
void checkStopped()
Definition: OverlayImpl.cpp:485
std::enable_shared_from_this
cstdint
ripple::OverlayImpl::app_
Application & app_
Definition: OverlayImpl.h:95
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:107
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:105
ripple::OverlayImpl::onPrepare
void onPrepare() override
Override called during preparation.
Definition: OverlayImpl.cpp:492
std::uint32_t
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:485
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:56
atomic
ripple::OverlayImpl::TrafficGauges::bytesIn
beast::insight::Gauge bytesIn
Definition: OverlayImpl.h:496
ripple::OverlayImpl::getActivePeers
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1179
memory
ripple::OverlayImpl::TrafficGauges::messagesIn
beast::insight::Gauge messagesIn
Definition: OverlayImpl.h:498
ripple::OverlayImpl::OverlayImpl
OverlayImpl(Application &app, Setup const &setup, Stoppable &parent, 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:113
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:1171
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
ripple::OverlayImpl::~OverlayImpl
~OverlayImpl()
Definition: OverlayImpl.cpp:160
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:60
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:106
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::OverlayImpl::networkID
boost::optional< std::uint32_t > networkID() const override
Returns the ID of the network this server is configured for, if any.
Definition: OverlayImpl.h:352
ripple::OverlayImpl::checkSanity
void checkSanity(std::uint32_t) override
Calls the checkSanity function on each peer.
Definition: OverlayImpl.cpp:1192
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:469
ripple::Overlay
Manages the set of connected peers.
Definition: Overlay.h:52
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:647
ripple::OverlayImpl::Timer
Definition: OverlayImpl.h:79
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:671
condition_variable
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:102
ripple::OverlayImpl::lastLink
void lastLink(std::uint32_t id)
Called when the last link from a peer chain is received.
Definition: OverlayImpl.cpp:850
ripple::OverlayImpl::check
void check() override
Calls the check function on each peer.
Definition: OverlayImpl.cpp:1199
ripple::OverlayImpl::Timer::Timer
Timer(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:67
ripple::OverlayImpl::Child::stop
virtual void stop()=0
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:73
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:1217
mutex
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(boost::beast::http::response< Body > const &response)
Definition: OverlayImpl.h:275
ripple::OverlayImpl::TrafficGauges::bytesOut
beast::insight::Gauge bytesOut
Definition: OverlayImpl.h:497
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:354
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
ripple::OverlayImpl::incPeerDisconnect
void incPeerDisconnect() override
Increment and retrieve counters for total peer disconnects, and disconnects we initiate for excessive...
Definition: OverlayImpl.h:328
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:101
ripple::OverlayImpl::csLast_
std::atomic< std::chrono::seconds > csLast_
Definition: OverlayImpl.h:119
ripple::OverlayImpl::jqTransOverflow_
std::atomic< uint64_t > jqTransOverflow_
Definition: OverlayImpl.h:114
ripple::OverlayImpl
Definition: OverlayImpl.h:55
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:756
ripple::OverlayImpl::crawlShards
Json::Value crawlShards(bool pubKey, std::uint32_t hops) override
Returns information reported to the crawl shard RPC command.
Definition: OverlayImpl.cpp:765
ripple::OverlayImpl::Stats::Stats
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector, std::vector< TrafficGauges > &&trafficGauges_)
Definition: OverlayImpl.h:505
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:58
ripple::OverlayImpl::peerDisconnects_
std::atomic< uint64_t > peerDisconnects_
Definition: OverlayImpl.h:115
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:377
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:109
ripple::OverlayImpl::TrafficGauges::messagesOut
beast::insight::Gauge messagesOut
Definition: OverlayImpl.h:499
unordered_map
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(http_request_type const &request)
Definition: OverlayImpl.cpp:337
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:435
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:77
ripple::OverlayImpl::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: OverlayImpl.cpp:622
std::set< std::uint32_t >
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:178
ripple::OverlayImpl::sendEndpoints
void sendEndpoints()
Definition: OverlayImpl.cpp:1324
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f) const
Definition: OverlayImpl.h:243
ripple::OverlayImpl::onStop
void onStop() override
Override called when the stop notification is issued.
Definition: OverlayImpl.cpp:603
ripple::PeerFinder::Manager
Maintains a set of IP addresses used for getting into the network.
Definition: PeerfinderManager.h:121
ripple::OverlayImpl::stop
void stop()
Definition: OverlayImpl.cpp:1284
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:872
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:1002
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:76
ripple::OverlayImpl::Stats
Definition: OverlayImpl.h:502