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 <boost/optional.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 <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 
85  explicit Timer(OverlayImpl& overlay);
86 
87  void
88  stop() override;
89 
90  void
91  run();
92 
93  void
94  on_timer(error_code ec);
95  };
96 
98  boost::asio::io_service& io_service_;
99  boost::optional<boost::asio::io_service::work> work_;
100  boost::asio::io_service::strand strand_;
101  mutable std::recursive_mutex mutex_; // VFALCO use std::mutex
104  boost::container::flat_map<Child*, std::weak_ptr<Child>> list_;
105  Setup setup_;
119 
120  // Last time we crawled peers for shard info. 'cs' = crawl shards
124  // Peer IDs expecting to receive a last link notification
126 
127  boost::optional<std::uint32_t> networkID_;
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  Stoppable& parent,
147  Resolver& resolver,
148  boost::asio::io_service& io_service,
149  BasicConfig const& config,
150  beast::insight::Collector::ptr const& collector);
151 
152  ~OverlayImpl();
153 
154  OverlayImpl(OverlayImpl const&) = delete;
155  OverlayImpl&
156  operator=(OverlayImpl const&) = delete;
157 
160  {
161  return *m_peerFinder;
162  }
163 
166  {
167  return m_resourceManager;
168  }
169 
172  {
173  return serverHandler_;
174  }
175 
176  Setup const&
177  setup() const
178  {
179  return setup_;
180  }
181 
182  Handoff
183  onHandoff(
185  http_request_type&& request,
186  endpoint_type remote_endpoint) override;
187 
188  void
189  connect(beast::IP::Endpoint const& remote_endpoint) override;
190 
191  int
192  limit() override;
193 
195  size() const override;
196 
198  json() override;
199 
201  getActivePeers() const override;
202 
203  void checkTracking(std::uint32_t) override;
204 
206  findPeerByShortID(Peer::id_t const& id) const override;
207 
209  findPeerByPublicKey(PublicKey const& pubKey) override;
210 
211  void
212  broadcast(protocol::TMProposeSet& m) override;
213 
214  void
215  broadcast(protocol::TMValidation& m) override;
216 
218  relay(
219  protocol::TMProposeSet& m,
220  uint256 const& uid,
221  PublicKey const& validator) override;
222 
224  relay(
225  protocol::TMValidation& m,
226  uint256 const& uid,
227  PublicKey const& validator) override;
228 
231 
232  //--------------------------------------------------------------------------
233  //
234  // OverlayImpl
235  //
236 
237  void
239 
240  void
242 
248  void
249  activate(std::shared_ptr<PeerImp> const& peer);
250 
251  // Called when an active peer is destroyed.
252  void
254 
255  // UnaryFunc will be called as
256  // void(std::shared_ptr<PeerImp>&&)
257  //
258  template <class UnaryFunc>
259  void
260  for_each(UnaryFunc&& f) const
261  {
263  {
264  std::lock_guard lock(mutex_);
265 
266  // Iterate over a copy of the peer list because peer
267  // destruction can invalidate iterators.
268  wp.reserve(ids_.size());
269 
270  for (auto& x : ids_)
271  wp.push_back(x.second);
272  }
273 
274  for (auto& w : wp)
275  {
276  if (auto p = w.lock())
277  f(std::move(p));
278  }
279  }
280 
281  // Called when TMManifests is received from a peer
282  void
283  onManifests(
285  std::shared_ptr<PeerImp> const& from);
286 
287  static bool
288  isPeerUpgrade(http_request_type const& request);
289 
290  template <class Body>
291  static bool
292  isPeerUpgrade(boost::beast::http::response<Body> const& response)
293  {
294  if (!is_upgrade(response))
295  return false;
296  return response.result() ==
297  boost::beast::http::status::switching_protocols;
298  }
299 
300  template <class Fields>
301  static bool
302  is_upgrade(boost::beast::http::header<true, Fields> const& req)
303  {
304  if (req.version() < 11)
305  return false;
306  if (req.method() != boost::beast::http::verb::get)
307  return false;
308  if (!boost::beast::http::token_list{req["Connection"]}.exists(
309  "upgrade"))
310  return false;
311  return true;
312  }
313 
314  template <class Fields>
315  static bool
316  is_upgrade(boost::beast::http::header<false, Fields> const& req)
317  {
318  if (req.version() < 11)
319  return false;
320  if (!boost::beast::http::token_list{req["Connection"]}.exists(
321  "upgrade"))
322  return false;
323  return true;
324  }
325 
326  static std::string
328 
329  void
330  reportTraffic(TrafficCount::category cat, bool isInbound, int bytes);
331 
332  void
334  {
336  }
337 
339  getJqTransOverflow() const override
340  {
341  return jqTransOverflow_;
342  }
343 
344  void
345  incPeerDisconnect() override
346  {
348  }
349 
351  getPeerDisconnect() const override
352  {
353  return peerDisconnects_;
354  }
355 
356  void
358  {
360  }
361 
363  getPeerDisconnectCharges() const override
364  {
366  }
367 
368  boost::optional<std::uint32_t>
369  networkID() const override
370  {
371  return networkID_;
372  }
373 
375  crawlShards(bool pubKey, std::uint32_t hops) override;
376 
381  void
383 
393  void
395  uint256 const& key,
396  PublicKey const& validator,
397  std::set<Peer::id_t>&& peers,
398  protocol::MessageType type);
399 
402  void
404  uint256 const& key,
405  PublicKey const& validator,
406  Peer::id_t peer,
407  protocol::MessageType type);
408 
414  void
416 
417 private:
418  void
419  squelch(
420  PublicKey const& validator,
421  Peer::id_t const id,
422  std::uint32_t squelchDuration) const override;
423 
424  void
425  unsquelch(PublicKey const& validator, Peer::id_t id) const override;
426 
430  http_request_type const& request,
431  address_type remote_address);
432 
436  http_request_type const& request,
437  address_type remote_address,
438  std::string msg);
439 
445  bool
446  processCrawl(http_request_type const& req, Handoff& handoff);
447 
455  bool
456  processValidatorList(http_request_type const& req, Handoff& handoff);
457 
463  bool
464  processHealth(http_request_type const& req, Handoff& handoff);
465 
470  bool
471  processRequest(http_request_type const& req, Handoff& handoff);
472 
478  getOverlayInfo();
479 
485  getServerInfo();
486 
492  getServerCounts();
493 
499  getUnlInfo();
500 
501  //--------------------------------------------------------------------------
502 
503  //
504  // Stoppable
505  //
506 
507  void
508  checkStopped();
509 
510  void
511  onPrepare() override;
512 
513  void
514  onStart() override;
515 
516  void
517  onStop() override;
518 
519  void
520  onChildrenStopped() override;
521 
522  //
523  // PropertyStream
524  //
525 
526  void
527  onWrite(beast::PropertyStream::Map& stream) override;
528 
529  //--------------------------------------------------------------------------
530 
531  void
532  remove(Child& child);
533 
534  void
535  stop();
536 
537  void
538  autoConnect();
539 
540  void
541  sendEndpoints();
542 
545  void
546  deleteIdlePeers();
547 
548 private:
550  {
552  char const* name,
553  beast::insight::Collector::ptr const& collector)
554  : bytesIn(collector->make_gauge(name, "Bytes_In"))
555  , bytesOut(collector->make_gauge(name, "Bytes_Out"))
556  , messagesIn(collector->make_gauge(name, "Messages_In"))
557  , messagesOut(collector->make_gauge(name, "Messages_Out"))
558  {
559  }
564  };
565 
566  struct Stats
567  {
568  template <class Handler>
570  Handler const& handler,
571  beast::insight::Collector::ptr const& collector,
572  std::vector<TrafficGauges>&& trafficGauges_)
573  : peerDisconnects(
574  collector->make_gauge("Overlay", "Peer_Disconnects"))
575  , trafficGauges(std::move(trafficGauges_))
576  , hook(collector->make_hook(handler))
577  {
578  }
579 
583  };
584 
587 
588 private:
589  void
591  {
592  auto counts = m_traffic.getCounts();
594  assert(counts.size() == m_stats.trafficGauges.size());
595 
596  for (std::size_t i = 0; i < counts.size(); ++i)
597  {
598  m_stats.trafficGauges[i].bytesIn = counts[i].bytesIn;
599  m_stats.trafficGauges[i].bytesOut = counts[i].bytesOut;
600  m_stats.trafficGauges[i].messagesIn = counts[i].messagesIn;
601  m_stats.trafficGauges[i].messagesOut = counts[i].messagesOut;
602  }
604  }
605 };
606 
607 } // namespace ripple
608 
609 #endif
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:586
ripple::OverlayImpl::Stats::hook
beast::insight::Hook hook
Definition: OverlayImpl.h:582
ripple::Application
Definition: Application.h:97
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:933
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:106
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: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:83
std::string
STL class.
std::shared_ptr< Message >
ripple::OverlayImpl::work_
boost::optional< boost::asio::io_service::work > work_
Definition: OverlayImpl.h:99
ripple::TrafficCount
Definition: TrafficCount.h:32
beast::PropertyStream::Map
Definition: PropertyStream.h:236
ripple::OverlayImpl::peerDisconnectsCharges_
std::atomic< uint64_t > peerDisconnectsCharges_
Definition: OverlayImpl.h:118
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:590
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:302
ripple::OverlayImpl::ids_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Definition: OverlayImpl.h:112
ripple::OverlayImpl::getJqTransOverflow
std::uint64_t getJqTransOverflow() const override
Definition: OverlayImpl.h:339
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::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:1407
ripple::OverlayImpl::autoConnect
void autoConnect()
Definition: OverlayImpl.cpp:1340
ripple::OverlayImpl::csIDs_
std::set< std::uint32_t > csIDs_
Definition: OverlayImpl.h:125
ripple::OverlayImpl::m_resolver
Resolver & m_resolver
Definition: OverlayImpl.h:113
ripple::OverlayImpl::mutex_
std::recursive_mutex mutex_
Definition: OverlayImpl.h:101
ripple::OverlayImpl::getPeerDisconnect
std::uint64_t getPeerDisconnect() const override
Definition: OverlayImpl.h:351
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:114
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:347
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:175
std::chrono::seconds
ripple::OverlayImpl::incPeerDisconnectCharges
void incPeerDisconnectCharges() override
Definition: OverlayImpl.h:357
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:100
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:905
std::lock_guard
STL class.
ripple::OverlayImpl::onStart
void onStart() override
Override called during start.
Definition: OverlayImpl.cpp:572
ripple::OverlayImpl::TrafficGauges::TrafficGauges
TrafficGauges(char const *name, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.h:551
ripple::OverlayImpl::broadcast
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1215
ripple::squelch::SquelchHandler
Abstract class.
Definition: overlay/Slot.h:71
ripple::OverlayImpl::connect
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Definition: OverlayImpl.cpp:402
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:970
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:177
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:115
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< false, Fields > const &req)
Definition: OverlayImpl.h:316
ripple::OverlayImpl::incJqTransOverflow
void incJqTransOverflow() override
Increment and retrieve counter for transaction job queue overflows.
Definition: OverlayImpl.h:333
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:1018
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:110
ripple::OverlayImpl::Stats::peerDisconnects
beast::insight::Gauge peerDisconnects
Definition: OverlayImpl.h:580
ripple::OverlayImpl::processHealth
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Definition: OverlayImpl.cpp:1064
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:105
std::condition_variable_any
ripple::OverlayImpl::onChildrenStopped
void onChildrenStopped() override
Override called when all children have stopped.
Definition: OverlayImpl.cpp:588
ripple::OverlayImpl::cond_
std::condition_variable_any cond_
Definition: OverlayImpl.h:102
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:159
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:73
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:844
ripple::OverlayImpl::checkTracking
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
Definition: OverlayImpl.cpp:1181
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:657
ripple::Stoppable
Provides an interface for starting and stopping.
Definition: Stoppable.h:201
ripple::OverlayImpl::manifestMessage_
std::shared_ptr< Message > manifestMessage_
Definition: OverlayImpl.h:132
ripple::OverlayImpl::resourceManager
Resource::Manager & resourceManager()
Definition: OverlayImpl.h:165
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:127
ripple::OverlayImpl::getPeerDisconnectCharges
std::uint64_t getPeerDisconnectCharges() const override
Definition: OverlayImpl.h:363
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:857
ripple::OverlayImpl::Stats::trafficGauges
std::vector< TrafficGauges > trafficGauges
Definition: OverlayImpl.h:581
chrono
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:98
ripple::ServerHandlerImp
Definition: ServerHandlerImp.h:46
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:585
ripple::OverlayImpl::serverHandler
ServerHandler & serverHandler()
Definition: OverlayImpl.h:171
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:939
ripple::OverlayImpl::checkStopped
void checkStopped()
Definition: OverlayImpl.cpp:490
std::enable_shared_from_this
cstdint
ripple::OverlayImpl::app_
Application & app_
Definition: OverlayImpl.h:97
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:109
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:107
ripple::OverlayImpl::onPrepare
void onPrepare() override
Override called during preparation.
Definition: OverlayImpl.cpp:497
std::uint32_t
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:549
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:56
atomic
ripple::OverlayImpl::TrafficGauges::bytesIn
beast::insight::Gauge bytesIn
Definition: OverlayImpl.h:560
ripple::OverlayImpl::getActivePeers
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1168
memory
ripple::OverlayImpl::TrafficGauges::messagesIn
beast::insight::Gauge messagesIn
Definition: OverlayImpl.h:562
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
ripple::OverlayImpl::deleteIdlePeers
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
Definition: OverlayImpl.cpp:1449
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:1160
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::~OverlayImpl
~OverlayImpl()
Definition: OverlayImpl.cpp:161
ripple::OverlayImpl::deletePeer
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Definition: OverlayImpl.cpp:1440
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:60
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:108
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:1222
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:369
ripple::OverlayImpl::getManifestsMessage
std::shared_ptr< Message > getManifestsMessage()
Definition: OverlayImpl.cpp:1267
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:474
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:626
ripple::OverlayImpl::Timer
Definition: OverlayImpl.h:81
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:650
condition_variable
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:104
ripple::OverlayImpl::lastLink
void lastLink(std::uint32_t id)
Called when the last link from a peer chain is received.
Definition: OverlayImpl.cpp:829
ripple::OverlayImpl::Timer::Timer
Timer(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:67
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:1393
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:1200
std::optional< std::uint32_t >
mutex
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(boost::beast::http::response< Body > const &response)
Definition: OverlayImpl.h:292
ripple::OverlayImpl::TrafficGauges::bytesOut
beast::insight::Gauge bytesOut
Definition: OverlayImpl.h:561
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:355
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
ripple::squelch::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
ripple::OverlayImpl::incPeerDisconnect
void incPeerDisconnect() override
Increment and retrieve counters for total peer disconnects, and disconnects we initiate for excessive...
Definition: OverlayImpl.h:345
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:103
ripple::OverlayImpl::csLast_
std::atomic< std::chrono::seconds > csLast_
Definition: OverlayImpl.h:121
ripple::OverlayImpl::jqTransOverflow_
std::atomic< uint64_t > jqTransOverflow_
Definition: OverlayImpl.h:116
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:1188
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:735
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:744
ripple::OverlayImpl::Stats::Stats
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector, std::vector< TrafficGauges > &&trafficGauges_)
Definition: OverlayImpl.h:569
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:60
ripple::OverlayImpl::peerDisconnects_
std::atomic< uint64_t > peerDisconnects_
Definition: OverlayImpl.h:117
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:382
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:111
ripple::OverlayImpl::TrafficGauges::messagesOut
beast::insight::Gauge messagesOut
Definition: OverlayImpl.h:563
unordered_map
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(http_request_type const &request)
Definition: OverlayImpl.cpp:338
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:440
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::slots_
squelch::Slots< UptimeClock > slots_
Definition: OverlayImpl.h:129
ripple::OverlayImpl::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: OverlayImpl.cpp:601
std::set< std::uint32_t >
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:178
ripple::OverlayImpl::manifestLock_
std::mutex manifestLock_
Definition: OverlayImpl.h:136
ripple::OverlayImpl::sendEndpoints
void sendEndpoints()
Definition: OverlayImpl.cpp:1348
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f) const
Definition: OverlayImpl.h:260
ripple::OverlayImpl::onStop
void onStop() override
Override called when the stop notification is issued.
Definition: OverlayImpl.cpp:582
ripple::PeerFinder::Manager
Maintains a set of IP addresses used for getting into the network.
Definition: PeerfinderManager.h:136
ripple::OverlayImpl::stop
void stop()
Definition: OverlayImpl.cpp:1308
ripple::OverlayImpl::unsquelch
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Definition: OverlayImpl.cpp:1380
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:851
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:981
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:78
ripple::OverlayImpl::Stats
Definition: OverlayImpl.h:566