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/core/Job.h>
25 #include <ripple/overlay/Overlay.h>
26 #include <ripple/overlay/impl/TrafficCount.h>
27 #include <ripple/server/Handoff.h>
28 #include <ripple/rpc/ServerHandler.h>
29 #include <ripple/basics/Resolver.h>
30 #include <ripple/basics/chrono.h>
31 #include <ripple/basics/UnorderedContainers.h>
32 #include <ripple/overlay/impl/Handshake.h>
33 #include <ripple/peerfinder/PeerfinderManager.h>
34 #include <ripple/resource/ResourceManager.h>
35 #include <boost/asio/ip/tcp.hpp>
36 #include <boost/asio/ssl/context.hpp>
37 #include <boost/asio/strand.hpp>
38 #include <boost/asio/basic_waitable_timer.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 constexpr std::uint32_t maxTTL = 2;
56 
57 class OverlayImpl : public Overlay
58 {
59 public:
60  class Child
61  {
62  protected:
64 
65  explicit
66  Child (OverlayImpl& overlay);
67 
68  virtual ~Child();
69 
70  public:
71  virtual void 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 
81  struct Timer
82  : Child
84  {
85  boost::asio::basic_waitable_timer <clock_type> timer_;
86 
87  explicit
88  Timer (OverlayImpl& overlay);
89 
90  void
91  stop() override;
92 
93  void
94  run();
95 
96  void
97  on_timer (error_code ec);
98  };
99 
101  boost::asio::io_service& io_service_;
102  boost::optional<boost::asio::io_service::work> work_;
103  boost::asio::io_service::strand strand_;
104  std::recursive_mutex mutex_; // VFALCO use std::mutex
107  boost::container::flat_map<
109  Setup setup_;
124 
125  // Last time we crawled peers for shard info. 'cs' = crawl shards
129  // Peer IDs expecting to receive a last link notification
131 
132  boost::optional<std::uint32_t> networkID_;
133 
134  //--------------------------------------------------------------------------
135 
136 public:
137  OverlayImpl (Application& app, Setup const& setup, Stoppable& parent,
139  Resolver& resolver, boost::asio::io_service& io_service,
140  BasicConfig const& config, beast::insight::Collector::ptr const& collector);
141 
142  ~OverlayImpl();
143 
144  OverlayImpl (OverlayImpl const&) = delete;
145  OverlayImpl& 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
173  http_request_type&& request,
174  endpoint_type remote_endpoint) override;
175 
176  void
177  connect(beast::IP::Endpoint const& remote_endpoint) override;
178 
179  int
180  limit() override;
181 
183  size() override;
184 
186  json() override;
187 
189  getActivePeers() override;
190 
191  void
192  check () override;
193 
194  void
195  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  send (protocol::TMProposeSet& m) override;
205 
206  void
207  send (protocol::TMValidation& m) override;
208 
209  void
210  relay (protocol::TMProposeSet& m,
211  uint256 const& uid) override;
212 
213  void
214  relay (protocol::TMValidation& m,
215  uint256 const& uid) override;
216 
217  //--------------------------------------------------------------------------
218  //
219  // OverlayImpl
220  //
221 
222  void
223  add_active (std::shared_ptr<PeerImp> const& peer);
224 
225  void
227 
233  void
234  activate (std::shared_ptr<PeerImp> const& peer);
235 
236  // Called when an active peer is destroyed.
237  void
239 
240  // UnaryFunc will be called as
241  // void(std::shared_ptr<PeerImp>&&)
242  //
243  template <class UnaryFunc>
244  void
245  for_each (UnaryFunc&& f)
246  {
248  {
249  std::lock_guard lock(mutex_);
250 
251  // Iterate over a copy of the peer list because peer
252  // destruction can invalidate iterators.
253  wp.reserve(ids_.size());
254 
255  for (auto& x : ids_)
256  wp.push_back(x.second);
257  }
258 
259  for (auto& w : wp)
260  {
261  if (auto p = w.lock())
262  f(std::move(p));
263  }
264  }
265 
268  bool(std::shared_ptr<Peer> const&)> score) override;
269 
270  // Called when TMManifests is received from a peer
271  void
272  onManifests (
274  std::shared_ptr<PeerImp> const& from);
275 
276  static
277  bool
278  isPeerUpgrade (http_request_type const& request);
279 
280  template<class Body>
281  static
282  bool
283  isPeerUpgrade (boost::beast::http::response<Body> const& response)
284  {
285  if (! is_upgrade(response))
286  return false;
287  return response.result() == boost::beast::http::status::switching_protocols;
288  }
289 
290  template<class Fields>
291  static
292  bool
293  is_upgrade(boost::beast::http::header<true, Fields> const& req)
294  {
295  if(req.version() < 11)
296  return false;
297  if(req.method() != boost::beast::http::verb::get)
298  return false;
299  if(! boost::beast::http::token_list{req["Connection"]}.exists("upgrade"))
300  return false;
301  return true;
302  }
303 
304  template<class Fields>
305  static
306  bool
307  is_upgrade(boost::beast::http::header<false, Fields> const& req)
308  {
309  if(req.version() < 11)
310  return false;
311  if(! boost::beast::http::token_list{req["Connection"]}.exists("upgrade"))
312  return false;
313  return true;
314  }
315 
316  static
319 
320  void
321  reportTraffic (
323  bool isInbound,
324  int bytes);
325 
326  void
328  {
330  }
331 
333  getJqTransOverflow() const override
334  {
335  return jqTransOverflow_;
336  }
337 
338  void
339  incPeerDisconnect() override
340  {
342  }
343 
345  getPeerDisconnect() const override
346  {
347  return peerDisconnects_;
348  }
349 
350  void
352  {
354  }
355 
357  getPeerDisconnectCharges() const override
358  {
360  }
361 
362  boost::optional<std::uint32_t>
363  networkID() const override
364  {
365  return networkID_;
366  }
367 
369  crawlShards(bool pubKey, std::uint32_t hops) override;
370 
375  void
377 
378 private:
381  http_request_type const& request, address_type remote_address);
382 
385  http_request_type const& request, address_type remote_address,
386  std::string msg);
387 
393  bool
394  processCrawl (http_request_type const& req,
395  Handoff& handoff);
396 
404  bool
406  Handoff& handoff);
407 
412  bool
413  processRequest (http_request_type const& req,
414  Handoff& handoff);
415 
421  getOverlayInfo();
422 
428  getServerInfo();
429 
435  getServerCounts();
436 
442  getUnlInfo();
443 
444  //--------------------------------------------------------------------------
445 
446  //
447  // Stoppable
448  //
449 
450  void
451  checkStopped();
452 
453  void
454  onPrepare() override;
455 
456  void
457  onStart() override;
458 
459  void
460  onStop() override;
461 
462  void
463  onChildrenStopped() override;
464 
465  //
466  // PropertyStream
467  //
468 
469  void
470  onWrite (beast::PropertyStream::Map& stream) override;
471 
472  //--------------------------------------------------------------------------
473 
474  void
475  remove (Child& child);
476 
477  void
478  stop();
479 
480  void
481  autoConnect();
482 
483  void
484  sendEndpoints();
485 
486 private:
487 
489  TrafficGauges (char const* name, 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 
503  struct Stats
504  {
505 
506  template <class Handler>
508  Handler const& handler,
509  beast::insight::Collector::ptr const& collector,
510  std::vector<TrafficGauges>&& trafficGauges_)
511  : peerDisconnects (collector->make_gauge("Overlay","Peer_Disconnects"))
512  , trafficGauges (std::move(trafficGauges_))
513  , hook (collector->make_hook (handler))
514  {
515  }
516 
520  };
521 
524 
525 private:
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 } // ripple
544 
545 #endif
beast::PropertyStream::Source::name
std::string const & name() const
Returns the name of this source.
Definition: beast_PropertyStream.cpp:189
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:1144
ripple::OverlayImpl::relay
void relay(protocol::TMProposeSet &m, uint256 const &uid) override
Relay a proposal.
Definition: OverlayImpl.cpp:1203
ripple::OverlayImpl::m_statsMutex
std::mutex m_statsMutex
Definition: OverlayImpl.h:523
ripple::OverlayImpl::Stats::hook
beast::insight::Hook hook
Definition: OverlayImpl.h:519
ripple::Application
Definition: Application.h:85
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:977
ripple::OverlayImpl::selectPeers
std::size_t selectPeers(PeerSet &set, std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> score) override
Select from active peers.
Definition: OverlayImpl.cpp:850
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:110
std::chrono::steady_clock
ripple::OverlayImpl::address_type
boost::asio::ip::address address_type
Definition: OverlayImpl.h:77
ripple::OverlayImpl::Timer::run
void run()
Definition: OverlayImpl.cpp:104
ripple::TrafficCount::getCounts
auto const & getCounts() const
An up-to-date copy of all the counters.
Definition: TrafficCount.h:177
ripple::OverlayImpl::Timer::timer_
boost::asio::basic_waitable_timer< clock_type > timer_
Definition: OverlayImpl.h:85
std::string
STL class.
std::shared_ptr< Collector >
ripple::OverlayImpl::work_
boost::optional< boost::asio::io_service::work > work_
Definition: OverlayImpl.h:102
ripple::TrafficCount
Definition: TrafficCount.h:32
beast::PropertyStream::Map
Definition: PropertyStream.h:185
ripple::OverlayImpl::peerDisconnectsCharges_
std::atomic< uint64_t > peerDisconnectsCharges_
Definition: OverlayImpl.h:123
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:526
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:293
ripple::OverlayImpl::ids_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Definition: OverlayImpl.h:117
ripple::OverlayImpl::getJqTransOverflow
std::uint64_t getJqTransOverflow() const override
Definition: OverlayImpl.h:333
ripple::maxTTL
constexpr std::uint32_t maxTTL
Definition: OverlayImpl.h:55
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:1278
ripple::OverlayImpl::csIDs_
std::set< std::uint32_t > csIDs_
Definition: OverlayImpl.h:130
ripple::OverlayImpl::m_resolver
Resolver & m_resolver
Definition: OverlayImpl.h:118
ripple::OverlayImpl::mutex_
std::recursive_mutex mutex_
Definition: OverlayImpl.h:104
ripple::OverlayImpl::getPeerDisconnect
std::uint64_t getPeerDisconnect() const override
Definition: OverlayImpl.h:345
ripple::OverlayImpl::Timer::on_timer
void on_timer(error_code ec)
Definition: OverlayImpl.cpp:113
std::vector
STL class.
ripple::OverlayImpl::next_id_
std::atomic< Peer::id_t > next_id_
Definition: OverlayImpl.h:119
ripple::OverlayImpl::makePrefix
static std::string makePrefix(std::uint32_t id)
Definition: OverlayImpl.cpp:349
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:196
std::chrono::seconds
ripple::OverlayImpl::incPeerDisconnectCharges
void incPeerDisconnectCharges() override
Definition: OverlayImpl.h:351
ripple::OverlayImpl::csCV_
std::condition_variable csCV_
Definition: OverlayImpl.h:128
std::recursive_mutex
STL class.
ripple::OverlayImpl::strand_
boost::asio::io_service::strand strand_
Definition: OverlayImpl.h:103
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:950
std::lock_guard
STL class.
ripple::OverlayImpl::onStart
void onStart() override
Override called during start.
Definition: OverlayImpl.cpp:584
ripple::OverlayImpl::TrafficGauges::TrafficGauges
TrafficGauges(char const *name, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.h:489
std::function
ripple::OverlayImpl::connect
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Definition: OverlayImpl.cpp:398
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:1013
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:166
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:120
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< false, Fields > const &req)
Definition: OverlayImpl.h:307
ripple::OverlayImpl::incJqTransOverflow
void incJqTransOverflow() override
Increment and retrieve counter for transaction job queue overflows.
Definition: OverlayImpl.h:327
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:1056
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:114
ripple::OverlayImpl::Stats::peerDisconnects
beast::insight::Gauge peerDisconnects
Definition: OverlayImpl.h:517
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:109
std::condition_variable_any
ripple::OverlayImpl::onChildrenStopped
void onChildrenStopped() override
Override called when all children have stopped.
Definition: OverlayImpl.cpp:600
ripple::OverlayImpl::cond_
std::condition_variable_any cond_
Definition: OverlayImpl.h:105
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f)
Definition: OverlayImpl.h:245
ripple::TrafficCount::category
category
Definition: TrafficCount.h:68
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::send
void send(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1171
ripple::OverlayImpl::operator=
OverlayImpl & operator=(OverlayImpl const &)=delete
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:108
ripple::OverlayImpl::csMutex_
std::mutex csMutex_
Definition: OverlayImpl.h:127
ripple::OverlayImpl::onManifests
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Definition: OverlayImpl.cpp:670
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::getActivePeers
PeerSequence getActivePeers() override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1112
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::networkID_
boost::optional< std::uint32_t > networkID_
Definition: OverlayImpl.h:132
ripple::OverlayImpl::getPeerDisconnectCharges
std::uint64_t getPeerDisconnectCharges() const override
Definition: OverlayImpl.h:357
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:897
ripple::OverlayImpl::Stats::trafficGauges
std::vector< TrafficGauges > trafficGauges
Definition: OverlayImpl.h:518
chrono
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:101
ripple::ServerHandlerImp
Definition: ServerHandlerImp.h:46
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:522
ripple::OverlayImpl::serverHandler
ServerHandler & serverHandler()
Definition: OverlayImpl.h:160
ripple::set
bool set(T &target, std::string const &name, Section const &section)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
Definition: BasicConfig.h:271
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:983
ripple::OverlayImpl::checkStopped
void checkStopped()
Definition: OverlayImpl.cpp:482
std::enable_shared_from_this
cstdint
ripple::OverlayImpl::app_
Application & app_
Definition: OverlayImpl.h:100
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:113
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:60
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:111
ripple::OverlayImpl::onPrepare
void onPrepare() override
Override called during preparation.
Definition: OverlayImpl.cpp:489
std::uint32_t
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:488
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:78
atomic
ripple::OverlayImpl::TrafficGauges::bytesIn
beast::insight::Gauge bytesIn
Definition: OverlayImpl.h:496
ripple::OverlayImpl::size
std::size_t size() override
The number of active peers on the network Active peers are only those peers that have completed the h...
Definition: OverlayImpl.cpp:884
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:139
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:1103
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
ripple::OverlayImpl::~OverlayImpl
~OverlayImpl()
Definition: OverlayImpl.cpp:182
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:83
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:112
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:363
ripple::OverlayImpl::checkSanity
void checkSanity(std::uint32_t) override
Calls the checkSanity function on each peer.
Definition: OverlayImpl.cpp:1126
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:466
ripple::Overlay
Manages the set of connected peers.
Definition: Overlay.h:47
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:638
ripple::OverlayImpl::Timer
Definition: OverlayImpl.h:81
ripple::PeerSet
Supports data retrieval by managing a set of peers.
Definition: PeerSet.h:48
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:663
condition_variable
ripple::OverlayImpl::lastLink
void lastLink(std::uint32_t id)
Called when the last link from a peer chain is received.
Definition: OverlayImpl.cpp:839
ripple::OverlayImpl::check
void check() override
Calls the check function on each peer.
Definition: OverlayImpl.cpp:1135
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:116
ripple::OverlayImpl::Timer::Timer
Timer(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:90
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:97
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:1156
mutex
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(boost::beast::http::response< Body > const &response)
Definition: OverlayImpl.h:283
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:357
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:339
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:106
ripple::OverlayImpl::csLast_
std::atomic< std::chrono::seconds > csLast_
Definition: OverlayImpl.h:126
ripple::OverlayImpl::jqTransOverflow_
std::atomic< uint64_t > jqTransOverflow_
Definition: OverlayImpl.h:121
ripple::OverlayImpl
Definition: OverlayImpl.h:57
ripple::Overlay::PeerSequence
std::vector< std::shared_ptr< Peer > > PeerSequence
Definition: Overlay.h:86
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:745
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:754
ripple::OverlayImpl::Stats::Stats
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector, std::vector< TrafficGauges > &&trafficGauges_)
Definition: OverlayImpl.h:507
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:60
ripple::OverlayImpl::peerDisconnects_
std::atomic< uint64_t > peerDisconnects_
Definition: OverlayImpl.h:122
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:379
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:340
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:430
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:613
std::set< std::uint32_t >
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:177
ripple::OverlayImpl::sendEndpoints
void sendEndpoints()
Definition: OverlayImpl.cpp:1286
ripple::OverlayImpl::onStop
void onStop() override
Override called when the stop notification is issued.
Definition: OverlayImpl.cpp:594
ripple::PeerFinder::Manager
Maintains a set of IP addresses used for getting into the network.
Definition: PeerfinderManager.h:122
ripple::OverlayImpl::stop
void stop()
Definition: OverlayImpl.cpp:1246
Json::Value
Represents a JSON value.
Definition: json_value.h:141
ripple::OverlayImpl::limit
int limit() override
Returns the maximum number of peers we are configured to allow.
Definition: OverlayImpl.cpp:891
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:1019
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:78
ripple::OverlayImpl::Stats
Definition: OverlayImpl.h:503