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/Slot.h>
30 #include <ripple/overlay/impl/Handshake.h>
31 #include <ripple/overlay/impl/TrafficCount.h>
32 #include <ripple/peerfinder/PeerfinderManager.h>
33 #include <ripple/resource/ResourceManager.h>
34 #include <ripple/rpc/ServerHandler.h>
35 #include <ripple/server/Handoff.h>
36 #include <boost/asio/basic_waitable_timer.hpp>
37 #include <boost/asio/ip/tcp.hpp>
38 #include <boost/asio/ssl/context.hpp>
39 #include <boost/asio/strand.hpp>
40 #include <boost/container/flat_map.hpp>
41 #include <boost/optional.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 <unordered_map>
50 
51 namespace ripple {
52 
53 class PeerImp;
54 class BasicConfig;
55 
57 {
58 public:
59  class Child
60  {
61  protected:
63 
64  explicit Child(OverlayImpl& overlay);
65 
66  virtual ~Child();
67 
68  public:
69  virtual void
70  stop() = 0;
71  };
72 
73 private:
75  using socket_type = boost::asio::ip::tcp::socket;
76  using address_type = boost::asio::ip::address;
77  using endpoint_type = boost::asio::ip::tcp::endpoint;
78  using error_code = boost::system::error_code;
79 
81  {
82  boost::asio::basic_waitable_timer<clock_type> timer_;
83 
84  explicit Timer(OverlayImpl& overlay);
85 
86  void
87  stop() override;
88 
89  void
90  run();
91 
92  void
93  on_timer(error_code ec);
94  };
95 
97  boost::asio::io_service& io_service_;
98  boost::optional<boost::asio::io_service::work> work_;
99  boost::asio::io_service::strand strand_;
100  mutable std::recursive_mutex mutex_; // VFALCO use std::mutex
103  boost::container::flat_map<Child*, std::weak_ptr<Child>> list_;
104  Setup setup_;
118 
119  // Last time we crawled peers for shard info. 'cs' = crawl shards
123  // Peer IDs expecting to receive a last link notification
125 
126  boost::optional<std::uint32_t> networkID_;
127 
129 
130  //--------------------------------------------------------------------------
131 
132 public:
133  OverlayImpl(
134  Application& app,
135  Setup const& setup,
136  Stoppable& parent,
139  Resolver& resolver,
140  boost::asio::io_service& io_service,
141  BasicConfig const& config,
142  beast::insight::Collector::ptr const& collector);
143 
144  ~OverlayImpl();
145 
146  OverlayImpl(OverlayImpl const&) = delete;
147  OverlayImpl&
148  operator=(OverlayImpl const&) = delete;
149 
152  {
153  return *m_peerFinder;
154  }
155 
158  {
159  return m_resourceManager;
160  }
161 
164  {
165  return serverHandler_;
166  }
167 
168  Setup const&
169  setup() const
170  {
171  return setup_;
172  }
173 
174  Handoff
175  onHandoff(
177  http_request_type&& request,
178  endpoint_type remote_endpoint) override;
179 
180  void
181  connect(beast::IP::Endpoint const& remote_endpoint) override;
182 
183  int
184  limit() override;
185 
187  size() const override;
188 
190  json() override;
191 
193  getActivePeers() const override;
194 
195  void
196  check() override;
197 
198  void checkSanity(std::uint32_t) override;
199 
201  findPeerByShortID(Peer::id_t const& id) const override;
202 
204  findPeerByPublicKey(PublicKey const& pubKey) override;
205 
206  void
207  broadcast(protocol::TMProposeSet& m) override;
208 
209  void
210  broadcast(protocol::TMValidation& m) override;
211 
213  relay(
214  protocol::TMProposeSet& m,
215  uint256 const& uid,
216  PublicKey const& validator) override;
217 
219  relay(
220  protocol::TMValidation& m,
221  uint256 const& uid,
222  PublicKey const& validator) override;
223 
224  //--------------------------------------------------------------------------
225  //
226  // OverlayImpl
227  //
228 
229  void
231 
232  void
234 
240  void
241  activate(std::shared_ptr<PeerImp> const& peer);
242 
243  // Called when an active peer is destroyed.
244  void
246 
247  // UnaryFunc will be called as
248  // void(std::shared_ptr<PeerImp>&&)
249  //
250  template <class UnaryFunc>
251  void
252  for_each(UnaryFunc&& f) const
253  {
255  {
256  std::lock_guard lock(mutex_);
257 
258  // Iterate over a copy of the peer list because peer
259  // destruction can invalidate iterators.
260  wp.reserve(ids_.size());
261 
262  for (auto& x : ids_)
263  wp.push_back(x.second);
264  }
265 
266  for (auto& w : wp)
267  {
268  if (auto p = w.lock())
269  f(std::move(p));
270  }
271  }
272 
273  // Called when TMManifests is received from a peer
274  void
275  onManifests(
277  std::shared_ptr<PeerImp> const& from);
278 
279  static bool
280  isPeerUpgrade(http_request_type const& request);
281 
282  template <class Body>
283  static bool
284  isPeerUpgrade(boost::beast::http::response<Body> const& response)
285  {
286  if (!is_upgrade(response))
287  return false;
288  return response.result() ==
289  boost::beast::http::status::switching_protocols;
290  }
291 
292  template <class Fields>
293  static bool
294  is_upgrade(boost::beast::http::header<true, Fields> const& req)
295  {
296  if (req.version() < 11)
297  return false;
298  if (req.method() != boost::beast::http::verb::get)
299  return false;
300  if (!boost::beast::http::token_list{req["Connection"]}.exists(
301  "upgrade"))
302  return false;
303  return true;
304  }
305 
306  template <class Fields>
307  static bool
308  is_upgrade(boost::beast::http::header<false, Fields> const& req)
309  {
310  if (req.version() < 11)
311  return false;
312  if (!boost::beast::http::token_list{req["Connection"]}.exists(
313  "upgrade"))
314  return false;
315  return true;
316  }
317 
318  static std::string
320 
321  void
322  reportTraffic(TrafficCount::category cat, bool isInbound, int bytes);
323 
324  void
326  {
328  }
329 
331  getJqTransOverflow() const override
332  {
333  return jqTransOverflow_;
334  }
335 
336  void
337  incPeerDisconnect() override
338  {
340  }
341 
343  getPeerDisconnect() const override
344  {
345  return peerDisconnects_;
346  }
347 
348  void
350  {
352  }
353 
355  getPeerDisconnectCharges() const override
356  {
358  }
359 
360  boost::optional<std::uint32_t>
361  networkID() const override
362  {
363  return networkID_;
364  }
365 
367  crawlShards(bool pubKey, std::uint32_t hops) override;
368 
373  void
375 
385  void
387  uint256 const& key,
388  PublicKey const& validator,
389  std::set<Peer::id_t>&& peers,
390  protocol::MessageType type);
391 
394  void
396  uint256 const& key,
397  PublicKey const& validator,
398  Peer::id_t peer,
399  protocol::MessageType type);
400 
406  void
408 
409 private:
410  void
411  squelch(
412  PublicKey const& validator,
413  Peer::id_t const id,
414  std::uint32_t squelchDuration) const override;
415 
416  void
417  unsquelch(PublicKey const& validator, Peer::id_t id) const override;
418 
422  http_request_type const& request,
423  address_type remote_address);
424 
428  http_request_type const& request,
429  address_type remote_address,
430  std::string msg);
431 
437  bool
438  processCrawl(http_request_type const& req, Handoff& handoff);
439 
447  bool
448  processValidatorList(http_request_type const& req, Handoff& handoff);
449 
455  bool
456  processHealth(http_request_type const& req, Handoff& handoff);
457 
462  bool
463  processRequest(http_request_type const& req, Handoff& handoff);
464 
470  getOverlayInfo();
471 
477  getServerInfo();
478 
484  getServerCounts();
485 
491  getUnlInfo();
492 
493  //--------------------------------------------------------------------------
494 
495  //
496  // Stoppable
497  //
498 
499  void
500  checkStopped();
501 
502  void
503  onPrepare() override;
504 
505  void
506  onStart() override;
507 
508  void
509  onStop() override;
510 
511  void
512  onChildrenStopped() override;
513 
514  //
515  // PropertyStream
516  //
517 
518  void
519  onWrite(beast::PropertyStream::Map& stream) override;
520 
521  //--------------------------------------------------------------------------
522 
523  void
524  remove(Child& child);
525 
526  void
527  stop();
528 
529  void
530  autoConnect();
531 
532  void
533  sendEndpoints();
534 
537  void
538  deleteIdlePeers();
539 
540 private:
542  {
544  char const* name,
545  beast::insight::Collector::ptr const& collector)
546  : bytesIn(collector->make_gauge(name, "Bytes_In"))
547  , bytesOut(collector->make_gauge(name, "Bytes_Out"))
548  , messagesIn(collector->make_gauge(name, "Messages_In"))
549  , messagesOut(collector->make_gauge(name, "Messages_Out"))
550  {
551  }
556  };
557 
558  struct Stats
559  {
560  template <class Handler>
562  Handler const& handler,
563  beast::insight::Collector::ptr const& collector,
564  std::vector<TrafficGauges>&& trafficGauges_)
565  : peerDisconnects(
566  collector->make_gauge("Overlay", "Peer_Disconnects"))
567  , trafficGauges(std::move(trafficGauges_))
568  , hook(collector->make_hook(handler))
569  {
570  }
571 
575  };
576 
579 
580 private:
581  void
583  {
584  auto counts = m_traffic.getCounts();
586  assert(counts.size() == m_stats.trafficGauges.size());
587 
588  for (std::size_t i = 0; i < counts.size(); ++i)
589  {
590  m_stats.trafficGauges[i].bytesIn = counts[i].bytesIn;
591  m_stats.trafficGauges[i].bytesOut = counts[i].bytesOut;
592  m_stats.trafficGauges[i].messagesIn = counts[i].messagesIn;
593  m_stats.trafficGauges[i].messagesOut = counts[i].messagesOut;
594  }
596  }
597 };
598 
599 } // namespace ripple
600 
601 #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:578
ripple::OverlayImpl::Stats::hook
beast::insight::Hook hook
Definition: OverlayImpl.h:574
ripple::Application
Definition: Application.h:97
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:962
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:105
std::chrono::steady_clock
ripple::OverlayImpl::address_type
boost::asio::ip::address address_type
Definition: OverlayImpl.h:76
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:82
std::string
STL class.
std::shared_ptr< Collector >
ripple::OverlayImpl::work_
boost::optional< boost::asio::io_service::work > work_
Definition: OverlayImpl.h:98
ripple::TrafficCount
Definition: TrafficCount.h:32
beast::PropertyStream::Map
Definition: PropertyStream.h:236
ripple::OverlayImpl::peerDisconnectsCharges_
std::atomic< uint64_t > peerDisconnectsCharges_
Definition: OverlayImpl.h:117
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:582
ripple::OverlayImpl::Child::overlay_
OverlayImpl & overlay_
Definition: OverlayImpl.h:62
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
Definition: OverlayImpl.h:294
ripple::OverlayImpl::ids_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Definition: OverlayImpl.h:111
ripple::OverlayImpl::getJqTransOverflow
std::uint64_t getJqTransOverflow() const override
Definition: OverlayImpl.h:331
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:1412
ripple::OverlayImpl::autoConnect
void autoConnect()
Definition: OverlayImpl.cpp:1345
ripple::OverlayImpl::csIDs_
std::set< std::uint32_t > csIDs_
Definition: OverlayImpl.h:124
ripple::OverlayImpl::m_resolver
Resolver & m_resolver
Definition: OverlayImpl.h:112
ripple::OverlayImpl::mutex_
std::recursive_mutex mutex_
Definition: OverlayImpl.h:100
ripple::OverlayImpl::getPeerDisconnect
std::uint64_t getPeerDisconnect() const override
Definition: OverlayImpl.h:343
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:113
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:350
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:178
std::chrono::seconds
ripple::OverlayImpl::incPeerDisconnectCharges
void incPeerDisconnectCharges() override
Definition: OverlayImpl.h:349
ripple::OverlayImpl::csCV_
std::condition_variable csCV_
Definition: OverlayImpl.h:122
std::recursive_mutex
STL class.
ripple::OverlayImpl::strand_
boost::asio::io_service::strand strand_
Definition: OverlayImpl.h:99
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:934
std::lock_guard
STL class.
ripple::OverlayImpl::onStart
void onStart() override
Override called during start.
Definition: OverlayImpl.cpp:601
ripple::OverlayImpl::TrafficGauges::TrafficGauges
TrafficGauges(char const *name, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.h:543
ripple::OverlayImpl::broadcast
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1250
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:405
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:999
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:169
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:114
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< false, Fields > const &req)
Definition: OverlayImpl.h:308
ripple::OverlayImpl::incJqTransOverflow
void incJqTransOverflow() override
Increment and retrieve counter for transaction job queue overflows.
Definition: OverlayImpl.h:325
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:1047
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:109
ripple::OverlayImpl::Stats::peerDisconnects
beast::insight::Gauge peerDisconnects
Definition: OverlayImpl.h:572
ripple::OverlayImpl::processHealth
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Definition: OverlayImpl.cpp:1093
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:104
std::condition_variable_any
ripple::OverlayImpl::onChildrenStopped
void onChildrenStopped() override
Override called when all children have stopped.
Definition: OverlayImpl.cpp:617
ripple::OverlayImpl::cond_
std::condition_variable_any cond_
Definition: OverlayImpl.h:101
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:151
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:873
ripple::OverlayImpl::operator=
OverlayImpl & operator=(OverlayImpl const &)=delete
ripple::OverlayImpl::csMutex_
std::mutex csMutex_
Definition: OverlayImpl.h:121
ripple::OverlayImpl::onManifests
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Definition: OverlayImpl.cpp:686
ripple::Stoppable
Provides an interface for starting and stopping.
Definition: Stoppable.h:201
ripple::OverlayImpl::resourceManager
Resource::Manager & resourceManager()
Definition: OverlayImpl.h:157
ripple::OverlayImpl::socket_type
boost::asio::ip::tcp::socket socket_type
Definition: OverlayImpl.h:75
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::OverlayImpl::networkID_
boost::optional< std::uint32_t > networkID_
Definition: OverlayImpl.h:126
ripple::OverlayImpl::getPeerDisconnectCharges
std::uint64_t getPeerDisconnectCharges() const override
Definition: OverlayImpl.h:355
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:886
ripple::OverlayImpl::Stats::trafficGauges
std::vector< TrafficGauges > trafficGauges
Definition: OverlayImpl.h:573
chrono
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:97
ripple::ServerHandlerImp
Definition: ServerHandlerImp.h:46
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:577
ripple::OverlayImpl::serverHandler
ServerHandler & serverHandler()
Definition: OverlayImpl.h:163
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:968
ripple::OverlayImpl::checkStopped
void checkStopped()
Definition: OverlayImpl.cpp:493
std::enable_shared_from_this
cstdint
ripple::OverlayImpl::app_
Application & app_
Definition: OverlayImpl.h:96
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:108
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:106
ripple::OverlayImpl::onPrepare
void onPrepare() override
Override called during preparation.
Definition: OverlayImpl.cpp:500
std::uint32_t
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:541
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:56
atomic
ripple::OverlayImpl::TrafficGauges::bytesIn
beast::insight::Gauge bytesIn
Definition: OverlayImpl.h:552
ripple::OverlayImpl::getActivePeers
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1197
memory
ripple::OverlayImpl::TrafficGauges::messagesIn
beast::insight::Gauge messagesIn
Definition: OverlayImpl.h:554
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:116
ripple::OverlayImpl::deleteIdlePeers
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
Definition: OverlayImpl.cpp:1454
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:1189
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
ripple::OverlayImpl::~OverlayImpl
~OverlayImpl()
Definition: OverlayImpl.cpp:164
ripple::OverlayImpl::deletePeer
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Definition: OverlayImpl.cpp:1445
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:60
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:107
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:1257
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:361
ripple::OverlayImpl::checkSanity
void checkSanity(std::uint32_t) override
Calls the checkSanity function on each peer.
Definition: OverlayImpl.cpp:1210
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:477
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:655
ripple::OverlayImpl::Timer
Definition: OverlayImpl.h:80
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:679
condition_variable
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:103
ripple::OverlayImpl::lastLink
void lastLink(std::uint32_t id)
Called when the last link from a peer chain is received.
Definition: OverlayImpl.cpp:858
ripple::OverlayImpl::check
void check() override
Calls the check function on each peer.
Definition: OverlayImpl.cpp:1217
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:1398
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:1235
mutex
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(boost::beast::http::response< Body > const &response)
Definition: OverlayImpl.h:284
ripple::OverlayImpl::TrafficGauges::bytesOut
beast::insight::Gauge bytesOut
Definition: OverlayImpl.h:553
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:358
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:337
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:102
ripple::OverlayImpl::csLast_
std::atomic< std::chrono::seconds > csLast_
Definition: OverlayImpl.h:120
ripple::OverlayImpl::jqTransOverflow_
std::atomic< uint64_t > jqTransOverflow_
Definition: OverlayImpl.h:115
ripple::OverlayImpl
Definition: OverlayImpl.h:56
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:1223
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:764
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:773
ripple::OverlayImpl::Stats::Stats
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector, std::vector< TrafficGauges > &&trafficGauges_)
Definition: OverlayImpl.h:561
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:59
ripple::OverlayImpl::peerDisconnects_
std::atomic< uint64_t > peerDisconnects_
Definition: OverlayImpl.h:116
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:385
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:110
ripple::OverlayImpl::TrafficGauges::messagesOut
beast::insight::Gauge messagesOut
Definition: OverlayImpl.h:555
unordered_map
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(http_request_type const &request)
Definition: OverlayImpl.cpp:341
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:443
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:78
ripple::OverlayImpl::slots_
squelch::Slots< UptimeClock > slots_
Definition: OverlayImpl.h:128
ripple::OverlayImpl::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: OverlayImpl.cpp:630
std::set< std::uint32_t >
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:178
ripple::OverlayImpl::sendEndpoints
void sendEndpoints()
Definition: OverlayImpl.cpp:1353
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f) const
Definition: OverlayImpl.h:252
ripple::OverlayImpl::onStop
void onStop() override
Override called when the stop notification is issued.
Definition: OverlayImpl.cpp:611
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:1313
ripple::OverlayImpl::unsquelch
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Definition: OverlayImpl.cpp:1385
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:880
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:1010
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:77
ripple::OverlayImpl::Stats
Definition: OverlayImpl.h:558