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/overlay/impl/TxMetrics.h>
34 #include <ripple/peerfinder/PeerfinderManager.h>
35 #include <ripple/resource/ResourceManager.h>
36 #include <ripple/rpc/ServerHandler.h>
37 #include <ripple/server/Handoff.h>
38 #include <boost/asio/basic_waitable_timer.hpp>
39 #include <boost/asio/ip/tcp.hpp>
40 #include <boost/asio/ssl/context.hpp>
41 #include <boost/asio/strand.hpp>
42 #include <boost/container/flat_map.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 <optional>
51 #include <unordered_map>
52 
53 namespace ripple {
54 
55 class PeerImp;
56 class BasicConfig;
57 
59 {
60 public:
61  class Child
62  {
63  protected:
65 
66  explicit Child(OverlayImpl& overlay);
67 
68  virtual ~Child();
69 
70  public:
71  virtual void
72  stop() = 0;
73  };
74 
75 private:
77  using socket_type = boost::asio::ip::tcp::socket;
78  using address_type = boost::asio::ip::address;
79  using endpoint_type = boost::asio::ip::tcp::endpoint;
80  using error_code = boost::system::error_code;
81 
83  {
84  boost::asio::basic_waitable_timer<clock_type> timer_;
85  bool stopping_{false};
86 
87  explicit Timer(OverlayImpl& overlay);
88 
89  void
90  stop() override;
91 
92  void
93  async_wait();
94 
95  void
96  on_timer(error_code ec);
97  };
98 
100  boost::asio::io_service& io_service_;
102  boost::asio::io_service::strand strand_;
103  mutable std::recursive_mutex mutex_; // VFALCO use std::mutex
106  boost::container::flat_map<Child*, std::weak_ptr<Child>> list_;
107  Setup setup_;
121 
122  // 'cs' = crawl shards
125  // Peer IDs expecting to receive a last link notification
127 
129 
130  // Transaction reduce-relay metrics
132 
133  // A message with the list of manifests we send to peers
135  // Used to track whether we need to update the cached list of manifests
137  // Protects the message and the sequence list of manifests
139 
140  //--------------------------------------------------------------------------
141 
142 public:
143  OverlayImpl(
144  Application& app,
145  Setup const& setup,
146  ServerHandler& serverHandler,
148  Resolver& resolver,
149  boost::asio::io_service& io_service,
150  BasicConfig const& config,
151  beast::insight::Collector::ptr const& collector);
152 
153  OverlayImpl(OverlayImpl const&) = delete;
154  OverlayImpl&
155  operator=(OverlayImpl const&) = delete;
156 
157  void
158  start() override;
159 
160  void
161  stop() override;
162 
165  {
166  return *m_peerFinder;
167  }
168 
171  {
172  return m_resourceManager;
173  }
174 
175  Setup const&
176  setup() const
177  {
178  return setup_;
179  }
180 
181  Handoff
182  onHandoff(
184  http_request_type&& request,
185  endpoint_type remote_endpoint) override;
186 
187  void
188  connect(beast::IP::Endpoint const& remote_endpoint) override;
189 
190  int
191  limit() override;
192 
194  size() const override;
195 
197  json() override;
198 
200  getActivePeers() const override;
201 
213  std::set<Peer::id_t> const& toSkip,
214  std::size_t& active,
215  std::size_t& disabled,
216  std::size_t& enabledInSkip) const;
217 
218  void checkTracking(std::uint32_t) override;
219 
221  findPeerByShortID(Peer::id_t const& id) const override;
222 
224  findPeerByPublicKey(PublicKey const& pubKey) override;
225 
226  void
227  broadcast(protocol::TMProposeSet& m) override;
228 
229  void
230  broadcast(protocol::TMValidation& m) override;
231 
233  relay(
234  protocol::TMProposeSet& m,
235  uint256 const& uid,
236  PublicKey const& validator) override;
237 
239  relay(
240  protocol::TMValidation& m,
241  uint256 const& uid,
242  PublicKey const& validator) override;
243 
244  void
245  relay(
246  uint256 const&,
247  protocol::TMTransaction& m,
248  std::set<Peer::id_t> const& skip) override;
249 
252 
253  //--------------------------------------------------------------------------
254  //
255  // OverlayImpl
256  //
257 
258  void
260 
261  void
263 
269  void
270  activate(std::shared_ptr<PeerImp> const& peer);
271 
272  // Called when an active peer is destroyed.
273  void
275 
276  // UnaryFunc will be called as
277  // void(std::shared_ptr<PeerImp>&&)
278  //
279  template <class UnaryFunc>
280  void
281  for_each(UnaryFunc&& f) const
282  {
284  {
285  std::lock_guard lock(mutex_);
286 
287  // Iterate over a copy of the peer list because peer
288  // destruction can invalidate iterators.
289  wp.reserve(ids_.size());
290 
291  for (auto& x : ids_)
292  wp.push_back(x.second);
293  }
294 
295  for (auto& w : wp)
296  {
297  if (auto p = w.lock())
298  f(std::move(p));
299  }
300  }
301 
302  // Called when TMManifests is received from a peer
303  void
304  onManifests(
306  std::shared_ptr<PeerImp> const& from);
307 
308  static bool
309  isPeerUpgrade(http_request_type const& request);
310 
311  template <class Body>
312  static bool
313  isPeerUpgrade(boost::beast::http::response<Body> const& response)
314  {
315  if (!is_upgrade(response))
316  return false;
317  return response.result() ==
318  boost::beast::http::status::switching_protocols;
319  }
320 
321  template <class Fields>
322  static bool
323  is_upgrade(boost::beast::http::header<true, Fields> const& req)
324  {
325  if (req.version() < 11)
326  return false;
327  if (req.method() != boost::beast::http::verb::get)
328  return false;
329  if (!boost::beast::http::token_list{req["Connection"]}.exists(
330  "upgrade"))
331  return false;
332  return true;
333  }
334 
335  template <class Fields>
336  static bool
337  is_upgrade(boost::beast::http::header<false, Fields> const& req)
338  {
339  if (req.version() < 11)
340  return false;
341  if (!boost::beast::http::token_list{req["Connection"]}.exists(
342  "upgrade"))
343  return false;
344  return true;
345  }
346 
347  static std::string
349 
350  void
351  reportTraffic(TrafficCount::category cat, bool isInbound, int bytes);
352 
353  void
355  {
357  }
358 
360  getJqTransOverflow() const override
361  {
362  return jqTransOverflow_;
363  }
364 
365  void
366  incPeerDisconnect() override
367  {
369  }
370 
372  getPeerDisconnect() const override
373  {
374  return peerDisconnects_;
375  }
376 
377  void
379  {
381  }
382 
384  getPeerDisconnectCharges() const override
385  {
387  }
388 
390  networkID() const override
391  {
392  return setup_.networkID;
393  }
394 
396  crawlShards(bool includePublicKey, std::uint32_t relays) override;
397 
402  void
404 
414  void
416  uint256 const& key,
417  PublicKey const& validator,
418  std::set<Peer::id_t>&& peers,
419  protocol::MessageType type);
420 
423  void
425  uint256 const& key,
426  PublicKey const& validator,
427  Peer::id_t peer,
428  protocol::MessageType type);
429 
435  void
437 
439  txMetrics() const override
440  {
441  return txMetrics_.json();
442  }
443 
445  template <typename... Args>
446  void
447  addTxMetrics(Args... args)
448  {
449  if (!strand_.running_in_this_thread())
450  return post(
451  strand_,
452  std::bind(&OverlayImpl::addTxMetrics<Args...>, this, args...));
453 
454  txMetrics_.addMetrics(args...);
455  }
456 
457 private:
458  void
459  squelch(
460  PublicKey const& validator,
461  Peer::id_t const id,
462  std::uint32_t squelchDuration) const override;
463 
464  void
465  unsquelch(PublicKey const& validator, Peer::id_t id) const override;
466 
470  http_request_type const& request,
471  address_type remote_address);
472 
476  http_request_type const& request,
477  address_type remote_address,
478  std::string msg);
479 
485  bool
486  processCrawl(http_request_type const& req, Handoff& handoff);
487 
495  bool
496  processValidatorList(http_request_type const& req, Handoff& handoff);
497 
503  bool
504  processHealth(http_request_type const& req, Handoff& handoff);
505 
510  bool
511  processRequest(http_request_type const& req, Handoff& handoff);
512 
518  getOverlayInfo();
519 
525  getServerInfo();
526 
532  getServerCounts();
533 
539  getUnlInfo();
540 
541  //--------------------------------------------------------------------------
542 
543  //
544  // PropertyStream
545  //
546 
547  void
548  onWrite(beast::PropertyStream::Map& stream) override;
549 
550  //--------------------------------------------------------------------------
551 
552  void
553  remove(Child& child);
554 
555  void
556  stopChildren();
557 
558  void
559  autoConnect();
560 
561  void
562  sendEndpoints();
563 
565  void
566  sendTxQueue();
567 
570  void
571  deleteIdlePeers();
572 
573 private:
575  {
577  char const* name,
578  beast::insight::Collector::ptr const& collector)
579  : bytesIn(collector->make_gauge(name, "Bytes_In"))
580  , bytesOut(collector->make_gauge(name, "Bytes_Out"))
581  , messagesIn(collector->make_gauge(name, "Messages_In"))
582  , messagesOut(collector->make_gauge(name, "Messages_Out"))
583  {
584  }
589  };
590 
591  struct Stats
592  {
593  template <class Handler>
595  Handler const& handler,
596  beast::insight::Collector::ptr const& collector,
597  std::vector<TrafficGauges>&& trafficGauges_)
598  : peerDisconnects(
599  collector->make_gauge("Overlay", "Peer_Disconnects"))
600  , trafficGauges(std::move(trafficGauges_))
601  , hook(collector->make_hook(handler))
602  {
603  }
604 
608  };
609 
612 
613 private:
614  void
616  {
617  auto counts = m_traffic.getCounts();
619  assert(counts.size() == m_stats.trafficGauges.size());
620 
621  for (std::size_t i = 0; i < counts.size(); ++i)
622  {
623  m_stats.trafficGauges[i].bytesIn = counts[i].bytesIn;
624  m_stats.trafficGauges[i].bytesOut = counts[i].bytesOut;
625  m_stats.trafficGauges[i].messagesIn = counts[i].messagesIn;
626  m_stats.trafficGauges[i].messagesOut = counts[i].messagesOut;
627  }
629  }
630 };
631 
632 } // namespace ripple
633 
634 #endif
ripple::OverlayImpl::OverlayImpl
OverlayImpl(Application &app, Setup const &setup, ServerHandler &serverHandler, Resource::Manager &resourceManager, Resolver &resolver, boost::asio::io_service &io_service, BasicConfig const &config, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.cpp:117
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:611
ripple::OverlayImpl::Stats::hook
beast::insight::Hook hook
Definition: OverlayImpl.h:607
ripple::Application
Definition: Application.h:115
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:885
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:108
std::chrono::steady_clock
ripple::OverlayImpl::address_type
boost::asio::ip::address address_type
Definition: OverlayImpl.h:78
ripple::reduce_relay::SquelchHandler
Abstract class.
Definition: overlay/Slot.h:71
ripple::TrafficCount::getCounts
auto const & getCounts() const
An up-to-date copy of all the counters.
Definition: TrafficCount.h:196
std::bind
T bind(T... args)
ripple::OverlayImpl::Timer::timer_
boost::asio::basic_waitable_timer< clock_type > timer_
Definition: OverlayImpl.h:84
std::string
STL class.
std::shared_ptr< Message >
ripple::TrafficCount
Definition: TrafficCount.h:32
ripple::Overlay::Setup::networkID
std::optional< std::uint32_t > networkID
Definition: Overlay.h:75
beast::PropertyStream::Map
Definition: PropertyStream.h:224
ripple::OverlayImpl::peerDisconnectsCharges_
std::atomic< uint64_t > peerDisconnectsCharges_
Definition: OverlayImpl.h:120
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:615
ripple::OverlayImpl::Child::overlay_
OverlayImpl & overlay_
Definition: OverlayImpl.h:64
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
Definition: OverlayImpl.h:323
ripple::OverlayImpl::ids_
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
Definition: OverlayImpl.h:114
ripple::OverlayImpl::getJqTransOverflow
std::uint64_t getJqTransOverflow() const override
Definition: OverlayImpl.h:360
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:1484
ripple::OverlayImpl::autoConnect
void autoConnect()
Definition: OverlayImpl.cpp:1410
ripple::OverlayImpl::endOfPeerChain
void endOfPeerChain(std::uint32_t id)
Called when the reply from the last peer in a peer chain is received.
Definition: OverlayImpl.cpp:774
ripple::OverlayImpl::stop
void stop() override
Definition: OverlayImpl.cpp:552
ripple::OverlayImpl::csIDs_
std::set< std::uint32_t > csIDs_
Definition: OverlayImpl.h:126
ripple::OverlayImpl::m_resolver
Resolver & m_resolver
Definition: OverlayImpl.h:115
ripple::OverlayImpl::mutex_
std::recursive_mutex mutex_
Definition: OverlayImpl.h:103
ripple::OverlayImpl::getPeerDisconnect
std::uint64_t getPeerDisconnect() const override
Definition: OverlayImpl.h:372
ripple::OverlayImpl::Timer::on_timer
void on_timer(error_code ec)
Definition: OverlayImpl.cpp:92
std::vector
STL class.
ripple::OverlayImpl::next_id_
std::atomic< Peer::id_t > next_id_
Definition: OverlayImpl.h:116
ripple::Overlay::PeerSequence
std::vector< std::shared_ptr< Peer > > PeerSequence
Definition: Overlay.h:79
ripple::OverlayImpl::makePrefix
static std::string makePrefix(std::uint32_t id)
Definition: OverlayImpl.cpp:335
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:163
ripple::OverlayImpl::incPeerDisconnectCharges
void incPeerDisconnectCharges() override
Definition: OverlayImpl.h:378
ripple::OverlayImpl::csCV_
std::condition_variable csCV_
Definition: OverlayImpl.h:124
std::recursive_mutex
STL class.
ripple::OverlayImpl::strand_
boost::asio::io_service::strand strand_
Definition: OverlayImpl.h:102
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:857
std::lock_guard
STL class.
ripple::OverlayImpl::stopChildren
void stopChildren()
Definition: OverlayImpl.cpp:1378
ripple::OverlayImpl::TrafficGauges::TrafficGauges
TrafficGauges(char const *name, beast::insight::Collector::ptr const &collector)
Definition: OverlayImpl.h:576
ripple::OverlayImpl::broadcast
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1224
ripple::OverlayImpl::connect
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Definition: OverlayImpl.cpp:390
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:922
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:176
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:117
ripple::OverlayImpl::is_upgrade
static bool is_upgrade(boost::beast::http::header< false, Fields > const &req)
Definition: OverlayImpl.h:337
ripple::OverlayImpl::incJqTransOverflow
void incJqTransOverflow() override
Increment and retrieve counter for transaction job queue overflows.
Definition: OverlayImpl.h:354
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:970
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:112
ripple::OverlayImpl::Stats::peerDisconnects
beast::insight::Gauge peerDisconnects
Definition: OverlayImpl.h:605
ripple::OverlayImpl::processHealth
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Definition: OverlayImpl.cpp:1038
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:107
std::condition_variable_any
ripple::OverlayImpl::start
void start() override
Definition: OverlayImpl.cpp:471
ripple::OverlayImpl::cond_
std::condition_variable_any cond_
Definition: OverlayImpl.h:104
ripple::OverlayImpl::sendTxQueue
void sendTxQueue()
Send once a second transactions' hashes aggregated by peers.
Definition: OverlayImpl.cpp:1436
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:164
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:788
ripple::OverlayImpl::checkTracking
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
Definition: OverlayImpl.cpp:1190
ripple::OverlayImpl::operator=
OverlayImpl & operator=(OverlayImpl const &)=delete
ripple::metrics::TxMetrics::json
Json::Value json() const
Get json representation of the metrics.
Definition: TxMetrics.cpp:117
ripple::OverlayImpl::csMutex_
std::mutex csMutex_
Definition: OverlayImpl.h:123
ripple::OverlayImpl::onManifests
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Definition: OverlayImpl.cpp:625
ripple::OverlayImpl::manifestMessage_
std::shared_ptr< Message > manifestMessage_
Definition: OverlayImpl.h:134
ripple::OverlayImpl::resourceManager
Resource::Manager & resourceManager()
Definition: OverlayImpl.h:170
ripple::OverlayImpl::socket_type
boost::asio::ip::tcp::socket socket_type
Definition: OverlayImpl.h:77
ripple::PublicKey
A public key.
Definition: PublicKey.h:59
ripple::OverlayImpl::getPeerDisconnectCharges
std::uint64_t getPeerDisconnectCharges() const override
Definition: OverlayImpl.h:384
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:801
ripple::OverlayImpl::Stats::trafficGauges
std::vector< TrafficGauges > trafficGauges
Definition: OverlayImpl.h:606
chrono
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:100
ripple::ServerHandlerImp
Definition: ServerHandlerImp.h:47
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::slots_
reduce_relay::Slots< UptimeClock > slots_
Definition: OverlayImpl.h:128
ripple::metrics::TxMetrics
Run transaction reduce-relay feature related metrics.
Definition: TxMetrics.h:88
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:610
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:891
std::enable_shared_from_this
ripple::reduce_relay::Slots
Slots is a container for validator's Slot and handles Slot update when a message is received from a v...
Definition: overlay/Slot.h:46
cstdint
ripple::OverlayImpl::app_
Application & app_
Definition: OverlayImpl.h:99
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:111
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:109
std::uint32_t
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:574
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:58
ripple::OverlayImpl::txMetrics
Json::Value txMetrics() const override
Returns tx reduce-relay metrics.
Definition: OverlayImpl.h:439
atomic
ripple::OverlayImpl::TrafficGauges::bytesIn
beast::insight::Gauge bytesIn
Definition: OverlayImpl.h:585
ripple::OverlayImpl::getActivePeers
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1144
ripple::OverlayImpl::Timer::async_wait
void async_wait()
Definition: OverlayImpl.cpp:84
memory
ripple::OverlayImpl::TrafficGauges::messagesIn
beast::insight::Gauge messagesIn
Definition: OverlayImpl.h:587
ripple::OverlayImpl::deleteIdlePeers
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
Definition: OverlayImpl.cpp:1526
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:1136
ripple::OverlayImpl::manifestListSeq_
std::optional< std::uint32_t > manifestListSeq_
Definition: OverlayImpl.h:136
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
ripple::OverlayImpl::networkID
std::optional< std::uint32_t > networkID() const override
Returns the ID of the network this server is configured for, if any.
Definition: OverlayImpl.h:390
ripple::OverlayImpl::deletePeer
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Definition: OverlayImpl.cpp:1517
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:62
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:110
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:1231
ripple::metrics::TxMetrics::addMetrics
void addMetrics(protocol::MessageType type, std::uint32_t val)
Add protocol message metrics.
Definition: TxMetrics.cpp:30
ripple::OverlayImpl::getManifestsMessage
std::shared_ptr< Message > getManifestsMessage()
Definition: OverlayImpl.cpp:1276
ripple::OverlayImpl::crawlShards
Json::Value crawlShards(bool includePublicKey, std::uint32_t relays) override
Returns information reported to the crawl shard RPC command.
Definition: OverlayImpl.cpp:687
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:462
ripple::Overlay
Manages the set of connected peers.
Definition: Overlay.h:51
std
STL namespace.
cassert
ripple::OverlayImpl::activate
void activate(std::shared_ptr< PeerImp > const &peer)
Called when a peer has connected successfully This is called after the peer handshake has been comple...
Definition: OverlayImpl.cpp:594
ripple::OverlayImpl::Timer
Definition: OverlayImpl.h:82
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:618
condition_variable
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:106
ripple::OverlayImpl::Timer::stopping_
bool stopping_
Definition: OverlayImpl.h:85
ripple::OverlayImpl::work_
std::optional< boost::asio::io_service::work > work_
Definition: OverlayImpl.h:101
ripple::OverlayImpl::Timer::Timer
Timer(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:69
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:1471
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:75
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:1209
optional
mutex
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(boost::beast::http::response< Body > const &response)
Definition: OverlayImpl.h:313
ripple::OverlayImpl::TrafficGauges::bytesOut
beast::insight::Gauge bytesOut
Definition: OverlayImpl.h:586
ripple::OverlayImpl::txMetrics_
metrics::TxMetrics txMetrics_
Definition: OverlayImpl.h:131
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:343
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
ripple::OverlayImpl::incPeerDisconnect
void incPeerDisconnect() override
Increment and retrieve counters for total peer disconnects, and disconnects we initiate for excessive...
Definition: OverlayImpl.h:366
ripple::OverlayImpl::addTxMetrics
void addTxMetrics(Args... args)
Add tx reduce-relay metrics.
Definition: OverlayImpl.h:447
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:105
ripple::OverlayImpl::jqTransOverflow_
std::atomic< uint64_t > jqTransOverflow_
Definition: OverlayImpl.h:118
ripple::OverlayImpl
Definition: OverlayImpl.h:58
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:1197
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:678
ripple::OverlayImpl::Stats::Stats
Stats(Handler const &handler, beast::insight::Collector::ptr const &collector, std::vector< TrafficGauges > &&trafficGauges_)
Definition: OverlayImpl.h:594
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:61
ripple::OverlayImpl::peerDisconnects_
std::atomic< uint64_t > peerDisconnects_
Definition: OverlayImpl.h:119
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handshake.h:47
std::unique_ptr
STL class.
ripple::OverlayImpl::makeErrorResponse
std::shared_ptr< Writer > makeErrorResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address, std::string msg)
Definition: OverlayImpl.cpp:370
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:113
ripple::OverlayImpl::TrafficGauges::messagesOut
beast::insight::Gauge messagesOut
Definition: OverlayImpl.h:588
unordered_map
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(http_request_type const &request)
Definition: OverlayImpl.cpp:326
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:428
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:80
ripple::OverlayImpl::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: OverlayImpl.cpp:569
std::set< std::uint32_t >
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:215
ripple::OverlayImpl::manifestLock_
std::mutex manifestLock_
Definition: OverlayImpl.h:138
ripple::OverlayImpl::sendEndpoints
void sendEndpoints()
Definition: OverlayImpl.cpp:1418
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f) const
Definition: OverlayImpl.h:281
ripple::PeerFinder::Manager
Maintains a set of IP addresses used for getting into the network.
Definition: PeerfinderManager.h:138
ripple::OverlayImpl::unsquelch
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Definition: OverlayImpl.cpp:1459
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:795
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:933
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:79
ripple::OverlayImpl::Stats
Definition: OverlayImpl.h:591