rippled
OverlayImpl.cpp
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 #include <ripple/app/ledger/LedgerMaster.h>
21 #include <ripple/app/misc/HashRouter.h>
22 #include <ripple/app/misc/NetworkOPs.h>
23 #include <ripple/app/misc/ValidatorList.h>
24 #include <ripple/app/misc/ValidatorSite.h>
25 #include <ripple/app/rdb/RelationalDatabase.h>
26 #include <ripple/app/rdb/Wallet.h>
27 #include <ripple/basics/base64.h>
28 #include <ripple/basics/make_SSLContext.h>
29 #include <ripple/basics/random.h>
30 #include <ripple/beast/core/LexicalCast.h>
31 #include <ripple/nodestore/DatabaseShard.h>
32 #include <ripple/overlay/Cluster.h>
33 #include <ripple/overlay/impl/ConnectAttempt.h>
34 #include <ripple/overlay/impl/InboundHandoff.h>
35 #include <ripple/overlay/impl/PeerImp.h>
36 #include <ripple/overlay/predicates.h>
37 #include <ripple/peerfinder/make_Manager.h>
38 #include <ripple/rpc/handlers/GetCounts.h>
39 #include <ripple/rpc/json_body.h>
40 #include <ripple/server/SimpleWriter.h>
41 
42 #include <boost/algorithm/string/predicate.hpp>
43 #include <boost/utility/in_place_factory.hpp>
44 
45 namespace ripple {
46 
47 namespace CrawlOptions {
48 enum {
49  Disabled = 0,
50  Overlay = (1 << 0),
51  ServerInfo = (1 << 1),
52  ServerCounts = (1 << 2),
53  Unl = (1 << 3)
54 };
55 }
56 
57 //------------------------------------------------------------------------------
58 
59 OverlayImpl::Child::Child(OverlayImpl& overlay) : overlay_(overlay)
60 {
61 }
62 
64 {
65  overlay_.remove(*this);
66 }
67 
68 //------------------------------------------------------------------------------
69 
71  : Child(overlay), timer_(overlay_.io_service_)
72 {
73 }
74 
75 void
77 {
78  // This method is only ever called from the same strand that calls
79  // Timer::on_timer, ensuring they never execute concurrently.
80  stopping_ = true;
81  timer_.cancel();
82 }
83 
84 void
86 {
87  timer_.expires_after(std::chrono::seconds(1));
88  timer_.async_wait(overlay_.strand_.wrap(std::bind(
89  &Timer::on_timer, shared_from_this(), std::placeholders::_1)));
90 }
91 
92 void
94 {
95  if (ec || stopping_)
96  {
97  if (ec && ec != boost::asio::error::operation_aborted)
98  {
99  JLOG(overlay_.journal_.error()) << "on_timer: " << ec.message();
100  }
101  return;
102  }
103 
104  overlay_.m_peerFinder->once_per_second();
105  overlay_.sendEndpoints();
106  overlay_.autoConnect();
107  if (overlay_.app_.config().TX_REDUCE_RELAY_ENABLE)
108  overlay_.sendTxQueue();
109 
110  if ((++overlay_.timer_count_ % Tuning::checkIdlePeers) == 0)
111  overlay_.deleteIdlePeers();
112 
113  async_wait();
114 }
115 
116 //------------------------------------------------------------------------------
117 
119  Application& app,
120  Setup const& setup,
121  ServerHandler& serverHandler,
123  Resolver& resolver,
124  boost::asio::io_service& io_service,
125  BasicConfig const& config,
126  beast::insight::Collector::ptr const& collector)
127  : app_(app)
128  , io_service_(io_service)
129  , work_(std::in_place, std::ref(io_service_))
131  , setup_(setup)
132  , journal_(app_.journal("Overlay"))
133  , serverHandler_(serverHandler)
135  , m_peerFinder(PeerFinder::make_Manager(
136  io_service,
137  stopwatch(),
138  app_.journal("PeerFinder"),
139  config,
140  collector))
141  , m_resolver(resolver)
142  , next_id_(1)
143  , timer_count_(0)
144  , slots_(app.logs(), *this)
145  , m_stats(
146  std::bind(&OverlayImpl::collect_metrics, this),
147  collector,
148  [counts = m_traffic.getCounts(), collector]() {
150  ret.reserve(counts.size());
151 
152  for (size_t i = 0; i < counts.size(); ++i)
153  {
154  ret.push_back(TrafficGauges(counts[i].name, collector));
155  }
156 
157  return ret;
158  }())
159 {
161 }
162 
163 Handoff
165  std::unique_ptr<stream_type>&& stream_ptr,
166  http_request_type&& request,
167  endpoint_type remote_endpoint)
168 {
169  auto const id = next_id_++;
170  beast::WrappedSink sink(app_.logs()["Peer"], makePrefix(id));
171  beast::Journal journal(sink);
172 
173  Handoff handoff;
174  if (processRequest(request, handoff))
175  return handoff;
176  if (!isPeerUpgrade(request))
177  return handoff;
178 
179  handoff.moved = true;
180 
181  JLOG(journal.debug()) << "Peer connection upgrade from " << remote_endpoint;
182 
183  error_code ec;
184  auto const local_endpoint(
185  stream_ptr->next_layer().socket().local_endpoint(ec));
186  if (ec)
187  {
188  JLOG(journal.debug()) << remote_endpoint << " failed: " << ec.message();
189  return handoff;
190  }
191 
192  auto consumer = m_resourceManager.newInboundEndpoint(
193  beast::IPAddressConversion::from_asio(remote_endpoint));
194  if (consumer.disconnect(journal))
195  return handoff;
196 
197  auto const slot = m_peerFinder->new_inbound_slot(
199  beast::IPAddressConversion::from_asio(remote_endpoint));
200 
201  if (slot == nullptr)
202  {
203  // self-connect, close
204  handoff.moved = false;
205  return handoff;
206  }
207 
208  // Validate HTTP request
209 
210  {
211  auto const types = beast::rfc2616::split_commas(request["Connect-As"]);
212  if (std::find_if(types.begin(), types.end(), [](std::string const& s) {
213  return boost::iequals(s, "peer");
214  }) == types.end())
215  {
216  handoff.moved = false;
217  handoff.response =
218  makeRedirectResponse(slot, request, remote_endpoint.address());
219  handoff.keep_alive = beast::rfc2616::is_keep_alive(request);
220  return handoff;
221  }
222  }
223 
224  auto const negotiatedVersion = negotiateProtocolVersion(request["Upgrade"]);
225  if (!negotiatedVersion)
226  {
227  m_peerFinder->on_closed(slot);
228  handoff.moved = false;
229  handoff.response = makeErrorResponse(
230  slot,
231  request,
232  remote_endpoint.address(),
233  "Unable to agree on a protocol version");
234  handoff.keep_alive = false;
235  return handoff;
236  }
237 
238  auto const sharedValue = makeSharedValue(*stream_ptr, journal);
239  if (!sharedValue)
240  {
241  m_peerFinder->on_closed(slot);
242  handoff.moved = false;
243  handoff.response = makeErrorResponse(
244  slot,
245  request,
246  remote_endpoint.address(),
247  "Incorrect security cookie");
248  handoff.keep_alive = false;
249  return handoff;
250  }
251 
252  try
253  {
254  auto publicKey = verifyHandshake(
255  request,
256  *sharedValue,
259  remote_endpoint.address(),
260  app_);
261 
262  {
263  // The node gets a reserved slot if it is in our cluster
264  // or if it has a reservation.
265  bool const reserved =
266  static_cast<bool>(app_.cluster().member(publicKey)) ||
267  app_.peerReservations().contains(publicKey);
268  auto const result =
269  m_peerFinder->activate(slot, publicKey, reserved);
270  if (result != PeerFinder::Result::success)
271  {
272  m_peerFinder->on_closed(slot);
273  JLOG(journal.debug())
274  << "Peer " << remote_endpoint << " redirected, slots full";
275  handoff.moved = false;
276  handoff.response = makeRedirectResponse(
277  slot, request, remote_endpoint.address());
278  handoff.keep_alive = false;
279  return handoff;
280  }
281  }
282 
283  auto const ih = std::make_shared<InboundHandoff>(
284  app_,
285  id,
286  slot,
287  std::move(request),
288  publicKey,
289  *negotiatedVersion,
290  consumer,
291  std::move(stream_ptr),
292  *this);
293  {
294  std::lock_guard<decltype(mutex_)> lock(mutex_);
295  list_.emplace(ih.get(), ih);
296 
297  ih->run();
298  }
299  handoff.moved = true;
300  return handoff;
301  }
302  catch (std::exception const& e)
303  {
304  JLOG(journal.debug()) << "Peer " << remote_endpoint
305  << " fails handshake (" << e.what() << ")";
306 
307  m_peerFinder->on_closed(slot);
308  handoff.moved = false;
309  handoff.response = makeErrorResponse(
310  slot, request, remote_endpoint.address(), e.what());
311  handoff.keep_alive = false;
312  return handoff;
313  }
314 }
315 
316 //------------------------------------------------------------------------------
317 
318 bool
320 {
321  if (!is_upgrade(request))
322  return false;
323  auto const versions = parseProtocolVersions(request["Upgrade"]);
324  return !versions.empty();
325 }
326 
329 {
331  ss << "[" << std::setfill('0') << std::setw(3) << id << "] ";
332  return ss.str();
333 }
334 
338  http_request_type const& request,
339  address_type remote_address)
340 {
341  boost::beast::http::response<json_body> msg;
342  msg.version(request.version());
343  msg.result(boost::beast::http::status::service_unavailable);
344  msg.insert("Server", BuildInfo::getFullVersionString());
345  {
346  std::ostringstream ostr;
347  ostr << remote_address;
348  msg.insert("Remote-Address", ostr.str());
349  }
350  msg.insert("Content-Type", "application/json");
351  msg.insert(boost::beast::http::field::connection, "close");
352  msg.body() = Json::objectValue;
353  {
354  Json::Value& ips = (msg.body()["peer-ips"] = Json::arrayValue);
355  for (auto const& _ : m_peerFinder->redirect(slot))
356  ips.append(_.address.to_string());
357  }
358  msg.prepare_payload();
359  return std::make_shared<SimpleWriter>(msg);
360 }
361 
365  http_request_type const& request,
366  address_type remote_address,
367  std::string text)
368 {
369  boost::beast::http::response<boost::beast::http::empty_body> msg;
370  msg.version(request.version());
371  msg.result(boost::beast::http::status::bad_request);
372  msg.reason("Bad Request (" + text + ")");
373  msg.insert("Server", BuildInfo::getFullVersionString());
374  msg.insert("Remote-Address", remote_address.to_string());
375  msg.insert(boost::beast::http::field::connection, "close");
376  msg.prepare_payload();
377  return std::make_shared<SimpleWriter>(msg);
378 }
379 
380 //------------------------------------------------------------------------------
381 
382 void
384 {
385  assert(work_);
386 
387  auto usage = resourceManager().newOutboundEndpoint(remote_endpoint);
388  if (usage.disconnect(journal_))
389  {
390  JLOG(journal_.info()) << "Over resource limit: " << remote_endpoint;
391  return;
392  }
393 
394  auto const slot = peerFinder().new_outbound_slot(remote_endpoint);
395  if (slot == nullptr)
396  {
397  JLOG(journal_.debug()) << "Connect: No slot for " << remote_endpoint;
398  return;
399  }
400 
401  auto const p = std::make_shared<ConnectAttempt>(
402  app_,
403  io_service_,
405  usage,
406  setup_.context,
407  next_id_++,
408  slot,
409  app_.journal("Peer"),
410  *this);
411 
412  std::lock_guard lock(mutex_);
413  list_.emplace(p.get(), p);
414  p->run();
415 }
416 
417 //------------------------------------------------------------------------------
418 
419 // Adds a peer that is already handshaked and active
420 void
422 {
423  std::lock_guard lock(mutex_);
424 
425  {
426  auto const result = m_peers.emplace(peer->slot(), peer);
427  assert(result.second);
428  (void)result.second;
429  }
430 
431  {
432  auto const result = ids_.emplace(
433  std::piecewise_construct,
434  std::make_tuple(peer->id()),
435  std::make_tuple(peer));
436  assert(result.second);
437  (void)result.second;
438  }
439 
440  list_.emplace(peer.get(), peer);
441 
442  JLOG(journal_.debug()) << "activated " << peer->getRemoteAddress() << " ("
443  << peer->id() << ":"
444  << toBase58(
445  TokenType::NodePublic, peer->getNodePublic())
446  << ")";
447 
448  // As we are not on the strand, run() must be called
449  // while holding the lock, otherwise new I/O can be
450  // queued after a call to stop().
451  peer->run();
452 }
453 
454 void
456 {
457  std::lock_guard lock(mutex_);
458  auto const iter = m_peers.find(slot);
459  assert(iter != m_peers.end());
460  m_peers.erase(iter);
461 }
462 
463 void
465 {
467  app_.config(),
468  serverHandler_.setup().overlay.port,
470  setup_.ipLimit);
471 
472  m_peerFinder->setConfig(config);
473  m_peerFinder->start();
474 
475  // Populate our boot cache: if there are no entries in [ips] then we use
476  // the entries in [ips_fixed].
477  auto bootstrapIps =
479 
480  // If nothing is specified, default to several well-known high-capacity
481  // servers to serve as bootstrap:
482  if (bootstrapIps.empty())
483  {
484  // Pool of servers operated by Ripple Labs Inc. - https://ripple.com
485  bootstrapIps.push_back("r.ripple.com 51235");
486 
487  // Pool of servers operated by Alloy Networks - https://www.alloy.ee
488  bootstrapIps.push_back("zaphod.alloy.ee 51235");
489 
490  // Pool of servers operated by ISRDC - https://isrdc.in
491  bootstrapIps.push_back("sahyadri.isrdc.in 51235");
492  }
493 
495  bootstrapIps,
496  [this](
497  std::string const& name,
498  std::vector<beast::IP::Endpoint> const& addresses) {
500  ips.reserve(addresses.size());
501  for (auto const& addr : addresses)
502  {
503  if (addr.port() == 0)
504  ips.push_back(to_string(addr.at_port(DEFAULT_PEER_PORT)));
505  else
506  ips.push_back(to_string(addr));
507  }
508 
509  std::string const base("config: ");
510  if (!ips.empty())
511  m_peerFinder->addFallbackStrings(base + name, ips);
512  });
513 
514  // Add the ips_fixed from the rippled.cfg file
515  if (!app_.config().standalone() && !app_.config().IPS_FIXED.empty())
516  {
519  [this](
520  std::string const& name,
521  std::vector<beast::IP::Endpoint> const& addresses) {
523  ips.reserve(addresses.size());
524 
525  for (auto& addr : addresses)
526  {
527  if (addr.port() == 0)
528  ips.emplace_back(addr.address(), DEFAULT_PEER_PORT);
529  else
530  ips.emplace_back(addr);
531  }
532 
533  if (!ips.empty())
534  m_peerFinder->addFixedPeer(name, ips);
535  });
536  }
537  auto const timer = std::make_shared<Timer>(*this);
538  std::lock_guard lock(mutex_);
539  list_.emplace(timer.get(), timer);
540  timer_ = timer;
541  timer->async_wait();
542 }
543 
544 void
546 {
547  strand_.dispatch(std::bind(&OverlayImpl::stopChildren, this));
548  {
549  std::unique_lock<decltype(mutex_)> lock(mutex_);
550  cond_.wait(lock, [this] { return list_.empty(); });
551  }
552  m_peerFinder->stop();
553 }
554 
555 //------------------------------------------------------------------------------
556 //
557 // PropertyStream
558 //
559 //------------------------------------------------------------------------------
560 
561 void
563 {
564  beast::PropertyStream::Set set("traffic", stream);
565  auto const stats = m_traffic.getCounts();
566  for (auto const& i : stats)
567  {
568  if (i)
569  {
571  item["category"] = i.name;
572  item["bytes_in"] = std::to_string(i.bytesIn.load());
573  item["messages_in"] = std::to_string(i.messagesIn.load());
574  item["bytes_out"] = std::to_string(i.bytesOut.load());
575  item["messages_out"] = std::to_string(i.messagesOut.load());
576  }
577  }
578 }
579 
580 //------------------------------------------------------------------------------
586 void
588 {
589  // Now track this peer
590  {
591  std::lock_guard lock(mutex_);
592  auto const result(ids_.emplace(
593  std::piecewise_construct,
594  std::make_tuple(peer->id()),
595  std::make_tuple(peer)));
596  assert(result.second);
597  (void)result.second;
598  }
599 
600  JLOG(journal_.debug()) << "activated " << peer->getRemoteAddress() << " ("
601  << peer->id() << ":"
602  << toBase58(
603  TokenType::NodePublic, peer->getNodePublic())
604  << ")";
605 
606  // We just accepted this peer so we have non-zero active peers
607  assert(size() != 0);
608 }
609 
610 void
612 {
613  std::lock_guard lock(mutex_);
614  ids_.erase(id);
615 }
616 
617 void
620  std::shared_ptr<PeerImp> const& from)
621 {
622  auto const n = m->list_size();
623  auto const& journal = from->pjournal();
624 
625  protocol::TMManifests relay;
626 
627  for (std::size_t i = 0; i < n; ++i)
628  {
629  auto& s = m->list().Get(i).stobject();
630 
631  if (auto mo = deserializeManifest(s))
632  {
633  auto const serialized = mo->serialized;
634 
635  auto const result =
636  app_.validatorManifests().applyManifest(std::move(*mo));
637 
638  if (result == ManifestDisposition::accepted)
639  {
640  relay.add_list()->set_stobject(s);
641 
642  // N.B.: this is important; the applyManifest call above moves
643  // the loaded Manifest out of the optional so we need to
644  // reload it here.
645  mo = deserializeManifest(serialized);
646  assert(mo);
647 
648  app_.getOPs().pubManifest(*mo);
649 
650  if (app_.validators().listed(mo->masterKey))
651  {
652  auto db = app_.getWalletDB().checkoutDb();
653  addValidatorManifest(*db, serialized);
654  }
655  }
656  }
657  else
658  {
659  JLOG(journal.debug())
660  << "Malformed manifest #" << i + 1 << ": " << strHex(s);
661  continue;
662  }
663  }
664 
665  if (!relay.list().empty())
666  for_each([m2 = std::make_shared<Message>(relay, protocol::mtMANIFESTS)](
667  std::shared_ptr<PeerImp>&& p) { p->send(m2); });
668 }
669 
670 void
673  bool isInbound,
674  int number)
675 {
676  m_traffic.addCount(cat, isInbound, number);
677 }
678 
680 OverlayImpl::crawlShards(bool includePublicKey, std::uint32_t relays)
681 {
682  using namespace std::chrono;
683 
685 
686  // Add shard info from this server to json result
687  if (auto shardStore = app_.getShardStore())
688  {
689  if (includePublicKey)
690  jv[jss::public_key] =
692 
693  auto const shardInfo{shardStore->getShardInfo()};
694  if (!shardInfo->finalized().empty())
695  jv[jss::complete_shards] = shardInfo->finalizedToString();
696  if (!shardInfo->incomplete().empty())
697  jv[jss::incomplete_shards] = shardInfo->incompleteToString();
698  }
699 
700  if (relays == 0 || size() == 0)
701  return jv;
702 
703  {
704  protocol::TMGetPeerShardInfoV2 tmGPS;
705  tmGPS.set_relays(relays);
706 
707  // Wait if a request is in progress
709  if (!csIDs_.empty())
710  csCV_.wait(csLock);
711 
712  {
713  std::lock_guard lock{mutex_};
714  for (auto const& id : ids_)
715  csIDs_.emplace(id.first);
716  }
717 
718  // Request peer shard info
719  foreach(send_always(std::make_shared<Message>(
720  tmGPS, protocol::mtGET_PEER_SHARD_INFO_V2)));
721 
722  if (csCV_.wait_for(csLock, seconds(60)) == std::cv_status::timeout)
723  {
724  csIDs_.clear();
725  csCV_.notify_all();
726  }
727  }
728 
729  // Combine shard info from peers
731  for_each([&](std::shared_ptr<PeerImp>&& peer) {
732  auto const psi{peer->getPeerShardInfos()};
733  for (auto const& [publicKey, shardInfo] : psi)
734  {
735  auto const it{peerShardInfo.find(publicKey)};
736  if (it == peerShardInfo.end())
737  peerShardInfo.emplace(publicKey, shardInfo);
738  else if (shardInfo.msgTimestamp() > it->second.msgTimestamp())
739  it->second = shardInfo;
740  }
741  });
742 
743  // Add shard info to json result
744  if (!peerShardInfo.empty())
745  {
746  auto& av = jv[jss::peers] = Json::Value(Json::arrayValue);
747  for (auto const& [publicKey, shardInfo] : peerShardInfo)
748  {
749  auto& pv{av.append(Json::Value(Json::objectValue))};
750  if (includePublicKey)
751  {
752  pv[jss::public_key] =
753  toBase58(TokenType::NodePublic, publicKey);
754  }
755 
756  if (!shardInfo.finalized().empty())
757  pv[jss::complete_shards] = shardInfo.finalizedToString();
758  if (!shardInfo.incomplete().empty())
759  pv[jss::incomplete_shards] = shardInfo.incompleteToString();
760  }
761  }
762 
763  return jv;
764 }
765 
766 void
768 {
769  // Notify threads if all peers have received a reply from all peer chains
770  std::lock_guard csLock{csMutex_};
771  csIDs_.erase(id);
772  if (csIDs_.empty())
773  csCV_.notify_all();
774 }
775 
782 {
783  std::lock_guard lock(mutex_);
784  return ids_.size();
785 }
786 
787 int
789 {
790  return m_peerFinder->config().maxPeers;
791 }
792 
795 {
796  using namespace std::chrono;
797  Json::Value jv;
798  auto& av = jv["active"] = Json::Value(Json::arrayValue);
799 
801  auto& pv = av.append(Json::Value(Json::objectValue));
802  pv[jss::public_key] = base64_encode(
803  sp->getNodePublic().data(), sp->getNodePublic().size());
804  pv[jss::type] = sp->slot()->inbound() ? "in" : "out";
805  pv[jss::uptime] = static_cast<std::uint32_t>(
806  duration_cast<seconds>(sp->uptime()).count());
807  if (sp->crawl())
808  {
809  pv[jss::ip] = sp->getRemoteAddress().address().to_string();
810  if (sp->slot()->inbound())
811  {
812  if (auto port = sp->slot()->listening_port())
813  pv[jss::port] = *port;
814  }
815  else
816  {
817  pv[jss::port] = std::to_string(sp->getRemoteAddress().port());
818  }
819  }
820 
821  {
822  auto version{sp->getVersion()};
823  if (!version.empty())
824  // Could move here if Json::value supported moving from strings
825  pv[jss::version] = version;
826  }
827 
828  std::uint32_t minSeq, maxSeq;
829  sp->ledgerRange(minSeq, maxSeq);
830  if (minSeq != 0 || maxSeq != 0)
831  pv[jss::complete_ledgers] =
832  std::to_string(minSeq) + "-" + std::to_string(maxSeq);
833 
834  auto const peerShardInfos{sp->getPeerShardInfos()};
835  auto const it{peerShardInfos.find(sp->getNodePublic())};
836  if (it != peerShardInfos.end())
837  {
838  auto const& shardInfo{it->second};
839  if (!shardInfo.finalized().empty())
840  pv[jss::complete_shards] = shardInfo.finalizedToString();
841  if (!shardInfo.incomplete().empty())
842  pv[jss::incomplete_shards] = shardInfo.incompleteToString();
843  }
844  });
845 
846  return jv;
847 }
848 
851 {
852  bool const humanReadable = false;
853  bool const admin = false;
854  bool const counters = false;
855 
856  Json::Value server_info =
857  app_.getOPs().getServerInfo(humanReadable, admin, counters);
858 
859  // Filter out some information
860  server_info.removeMember(jss::hostid);
861  server_info.removeMember(jss::load_factor_fee_escalation);
862  server_info.removeMember(jss::load_factor_fee_queue);
863  server_info.removeMember(jss::validation_quorum);
864 
865  if (server_info.isMember(jss::validated_ledger))
866  {
867  Json::Value& validated_ledger = server_info[jss::validated_ledger];
868 
869  validated_ledger.removeMember(jss::base_fee);
870  validated_ledger.removeMember(jss::reserve_base_xrp);
871  validated_ledger.removeMember(jss::reserve_inc_xrp);
872  }
873 
874  return server_info;
875 }
876 
879 {
880  return getCountsJson(app_, 10);
881 }
882 
885 {
886  Json::Value validators = app_.validators().getJson();
887 
888  if (validators.isMember(jss::publisher_lists))
889  {
890  Json::Value& publisher_lists = validators[jss::publisher_lists];
891 
892  for (auto& publisher : publisher_lists)
893  {
894  publisher.removeMember(jss::list);
895  }
896  }
897 
898  validators.removeMember(jss::signing_keys);
899  validators.removeMember(jss::trusted_validator_keys);
900  validators.removeMember(jss::validation_quorum);
901 
902  Json::Value validatorSites = app_.validatorSites().getJson();
903 
904  if (validatorSites.isMember(jss::validator_sites))
905  {
906  validators[jss::validator_sites] =
907  std::move(validatorSites[jss::validator_sites]);
908  }
909 
910  return validators;
911 }
912 
913 // Returns information on verified peers.
916 {
918  for (auto const& peer : getActivePeers())
919  {
920  json.append(peer->json());
921  }
922  return json;
923 }
924 
925 bool
927 {
928  if (req.target() != "/crawl" ||
930  return false;
931 
932  boost::beast::http::response<json_body> msg;
933  msg.version(req.version());
934  msg.result(boost::beast::http::status::ok);
935  msg.insert("Server", BuildInfo::getFullVersionString());
936  msg.insert("Content-Type", "application/json");
937  msg.insert("Connection", "close");
938  msg.body()["version"] = Json::Value(2u);
939 
941  {
942  msg.body()["overlay"] = getOverlayInfo();
943  }
945  {
946  msg.body()["server"] = getServerInfo();
947  }
949  {
950  msg.body()["counts"] = getServerCounts();
951  }
953  {
954  msg.body()["unl"] = getUnlInfo();
955  }
956 
957  msg.prepare_payload();
958  handoff.response = std::make_shared<SimpleWriter>(msg);
959  return true;
960 }
961 
962 bool
964  http_request_type const& req,
965  Handoff& handoff)
966 {
967  // If the target is in the form "/vl/<validator_list_public_key>",
968  // return the most recent validator list for that key.
969  constexpr std::string_view prefix("/vl/");
970 
971  if (!req.target().starts_with(prefix.data()) || !setup_.vlEnabled)
972  return false;
973 
974  std::uint32_t version = 1;
975 
976  boost::beast::http::response<json_body> msg;
977  msg.version(req.version());
978  msg.insert("Server", BuildInfo::getFullVersionString());
979  msg.insert("Content-Type", "application/json");
980  msg.insert("Connection", "close");
981 
982  auto fail = [&msg, &handoff](auto status) {
983  msg.result(status);
984  msg.insert("Content-Length", "0");
985 
986  msg.body() = Json::nullValue;
987 
988  msg.prepare_payload();
989  handoff.response = std::make_shared<SimpleWriter>(msg);
990  return true;
991  };
992 
993  auto key = req.target().substr(prefix.size());
994 
995  if (auto slash = key.find('/'); slash != boost::string_view::npos)
996  {
997  auto verString = key.substr(0, slash);
998  if (!boost::conversion::try_lexical_convert(verString, version))
999  return fail(boost::beast::http::status::bad_request);
1000  key = key.substr(slash + 1);
1001  }
1002 
1003  if (key.empty())
1004  return fail(boost::beast::http::status::bad_request);
1005 
1006  // find the list
1007  auto vl = app_.validators().getAvailable(key, version);
1008 
1009  if (!vl)
1010  {
1011  // 404 not found
1012  return fail(boost::beast::http::status::not_found);
1013  }
1014  else if (!*vl)
1015  {
1016  return fail(boost::beast::http::status::bad_request);
1017  }
1018  else
1019  {
1020  msg.result(boost::beast::http::status::ok);
1021 
1022  msg.body() = *vl;
1023 
1024  msg.prepare_payload();
1025  handoff.response = std::make_shared<SimpleWriter>(msg);
1026  return true;
1027  }
1028 }
1029 
1030 bool
1032 {
1033  if (req.target() != "/health")
1034  return false;
1035  boost::beast::http::response<json_body> msg;
1036  msg.version(req.version());
1037  msg.insert("Server", BuildInfo::getFullVersionString());
1038  msg.insert("Content-Type", "application/json");
1039  msg.insert("Connection", "close");
1040 
1041  auto info = getServerInfo();
1042 
1043  int last_validated_ledger_age = -1;
1044  if (info.isMember(jss::validated_ledger))
1045  last_validated_ledger_age =
1046  info[jss::validated_ledger][jss::age].asInt();
1047  bool amendment_blocked = false;
1048  if (info.isMember(jss::amendment_blocked))
1049  amendment_blocked = true;
1050  int number_peers = info[jss::peers].asInt();
1051  std::string server_state = info[jss::server_state].asString();
1052  auto load_factor = info[jss::load_factor_server].asDouble() /
1053  info[jss::load_base].asDouble();
1054 
1055  enum { healthy, warning, critical };
1056  int health = healthy;
1057  auto set_health = [&health](int state) {
1058  if (health < state)
1059  health = state;
1060  };
1061 
1062  msg.body()[jss::info] = Json::objectValue;
1063  if (last_validated_ledger_age >= 7 || last_validated_ledger_age < 0)
1064  {
1065  msg.body()[jss::info][jss::validated_ledger] =
1066  last_validated_ledger_age;
1067  if (last_validated_ledger_age < 20)
1068  set_health(warning);
1069  else
1070  set_health(critical);
1071  }
1072 
1073  if (amendment_blocked)
1074  {
1075  msg.body()[jss::info][jss::amendment_blocked] = true;
1076  set_health(critical);
1077  }
1078 
1079  if (number_peers <= 7)
1080  {
1081  msg.body()[jss::info][jss::peers] = number_peers;
1082  if (number_peers != 0)
1083  set_health(warning);
1084  else
1085  set_health(critical);
1086  }
1087 
1088  if (!(server_state == "full" || server_state == "validating" ||
1089  server_state == "proposing"))
1090  {
1091  msg.body()[jss::info][jss::server_state] = server_state;
1092  if (server_state == "syncing" || server_state == "tracking" ||
1093  server_state == "connected")
1094  {
1095  set_health(warning);
1096  }
1097  else
1098  set_health(critical);
1099  }
1100 
1101  if (load_factor > 100)
1102  {
1103  msg.body()[jss::info][jss::load_factor] = load_factor;
1104  if (load_factor < 1000)
1105  set_health(warning);
1106  else
1107  set_health(critical);
1108  }
1109 
1110  switch (health)
1111  {
1112  case healthy:
1113  msg.result(boost::beast::http::status::ok);
1114  break;
1115  case warning:
1116  msg.result(boost::beast::http::status::service_unavailable);
1117  break;
1118  case critical:
1119  msg.result(boost::beast::http::status::internal_server_error);
1120  break;
1121  }
1122 
1123  msg.prepare_payload();
1124  handoff.response = std::make_shared<SimpleWriter>(msg);
1125  return true;
1126 }
1127 
1128 bool
1130 {
1131  // Take advantage of || short-circuiting
1132  return processCrawl(req, handoff) || processValidatorList(req, handoff) ||
1133  processHealth(req, handoff);
1134 }
1135 
1138 {
1140  ret.reserve(size());
1141 
1142  for_each([&ret](std::shared_ptr<PeerImp>&& sp) {
1143  ret.emplace_back(std::move(sp));
1144  });
1145 
1146  return ret;
1147 }
1148 
1151  std::set<Peer::id_t> const& toSkip,
1152  std::size_t& active,
1153  std::size_t& disabled,
1154  std::size_t& enabledInSkip) const
1155 {
1157  std::lock_guard lock(mutex_);
1158 
1159  active = ids_.size();
1160  disabled = enabledInSkip = 0;
1161  ret.reserve(ids_.size());
1162 
1163  for (auto& [id, w] : ids_)
1164  {
1165  if (auto p = w.lock())
1166  {
1167  bool const reduceRelayEnabled = p->txReduceRelayEnabled();
1168  // tx reduced relay feature disabled
1169  if (!reduceRelayEnabled)
1170  ++disabled;
1171 
1172  if (toSkip.count(id) == 0)
1173  ret.emplace_back(std::move(p));
1174  else if (reduceRelayEnabled)
1175  ++enabledInSkip;
1176  }
1177  }
1178 
1179  return ret;
1180 }
1181 
1182 void
1184 {
1185  for_each(
1186  [index](std::shared_ptr<PeerImp>&& sp) { sp->checkTracking(index); });
1187 }
1188 
1191 {
1192  std::lock_guard lock(mutex_);
1193  auto const iter = ids_.find(id);
1194  if (iter != ids_.end())
1195  return iter->second.lock();
1196  return {};
1197 }
1198 
1199 // A public key hash map was not used due to the peer connect/disconnect
1200 // update overhead outweighing the performance of a small set linear search.
1203 {
1204  std::lock_guard lock(mutex_);
1205  for (auto const& e : ids_)
1206  {
1207  if (auto peer = e.second.lock())
1208  {
1209  if (peer->getNodePublic() == pubKey)
1210  return peer;
1211  }
1212  }
1213  return {};
1214 }
1215 
1216 void
1217 OverlayImpl::broadcast(protocol::TMProposeSet& m)
1218 {
1219  auto const sm = std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER);
1220  for_each([&](std::shared_ptr<PeerImp>&& p) { p->send(sm); });
1221 }
1222 
1225  protocol::TMProposeSet& m,
1226  uint256 const& uid,
1227  PublicKey const& validator)
1228 {
1229  if (auto const toSkip = app_.getHashRouter().shouldRelay(uid))
1230  {
1231  auto const sm =
1232  std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER, validator);
1234  if (toSkip->find(p->id()) == toSkip->end())
1235  p->send(sm);
1236  });
1237  return *toSkip;
1238  }
1239  return {};
1240 }
1241 
1242 void
1243 OverlayImpl::broadcast(protocol::TMValidation& m)
1244 {
1245  auto const sm = std::make_shared<Message>(m, protocol::mtVALIDATION);
1246  for_each([sm](std::shared_ptr<PeerImp>&& p) { p->send(sm); });
1247 }
1248 
1251  protocol::TMValidation& m,
1252  uint256 const& uid,
1253  PublicKey const& validator)
1254 {
1255  if (auto const toSkip = app_.getHashRouter().shouldRelay(uid))
1256  {
1257  auto const sm =
1258  std::make_shared<Message>(m, protocol::mtVALIDATION, validator);
1260  if (toSkip->find(p->id()) == toSkip->end())
1261  p->send(sm);
1262  });
1263  return *toSkip;
1264  }
1265  return {};
1266 }
1267 
1270 {
1272 
1273  if (auto seq = app_.validatorManifests().sequence();
1274  seq != manifestListSeq_)
1275  {
1276  protocol::TMManifests tm;
1277 
1279  [&tm](std::size_t s) { tm.mutable_list()->Reserve(s); },
1280  [&tm, &hr = app_.getHashRouter()](Manifest const& manifest) {
1281  tm.add_list()->set_stobject(
1282  manifest.serialized.data(), manifest.serialized.size());
1283  hr.addSuppression(manifest.hash());
1284  });
1285 
1287 
1288  if (tm.list_size() != 0)
1290  std::make_shared<Message>(tm, protocol::mtMANIFESTS);
1291 
1292  manifestListSeq_ = seq;
1293  }
1294 
1295  return manifestMessage_;
1296 }
1297 
1298 void
1300  uint256 const& hash,
1301  protocol::TMTransaction& m,
1302  std::set<Peer::id_t> const& toSkip)
1303 {
1304  auto const sm = std::make_shared<Message>(m, protocol::mtTRANSACTION);
1305  std::size_t total = 0;
1306  std::size_t disabled = 0;
1307  std::size_t enabledInSkip = 0;
1308 
1309  // total peers excluding peers in toSkip
1310  auto peers = getActivePeers(toSkip, total, disabled, enabledInSkip);
1311  auto minRelay = app_.config().TX_REDUCE_RELAY_MIN_PEERS + disabled;
1312 
1313  if (!app_.config().TX_REDUCE_RELAY_ENABLE || total <= minRelay)
1314  {
1315  for (auto const& p : peers)
1316  p->send(sm);
1319  txMetrics_.addMetrics(total, toSkip.size(), 0);
1320  return;
1321  }
1322 
1323  // We have more peers than the minimum (disabled + minimum enabled),
1324  // relay to all disabled and some randomly selected enabled that
1325  // do not have the transaction.
1326  auto enabledTarget = app_.config().TX_REDUCE_RELAY_MIN_PEERS +
1327  (total - minRelay) * app_.config().TX_RELAY_PERCENTAGE / 100;
1328 
1329  txMetrics_.addMetrics(enabledTarget, toSkip.size(), disabled);
1330 
1331  if (enabledTarget > enabledInSkip)
1332  std::shuffle(peers.begin(), peers.end(), default_prng());
1333 
1334  JLOG(journal_.trace()) << "relaying tx, total peers " << peers.size()
1335  << " selected " << enabledTarget << " skip "
1336  << toSkip.size() << " disabled " << disabled;
1337 
1338  // count skipped peers with the enabled feature towards the quota
1339  std::uint16_t enabledAndRelayed = enabledInSkip;
1340  for (auto const& p : peers)
1341  {
1342  // always relay to a peer with the disabled feature
1343  if (!p->txReduceRelayEnabled())
1344  {
1345  p->send(sm);
1346  }
1347  else if (enabledAndRelayed < enabledTarget)
1348  {
1349  enabledAndRelayed++;
1350  p->send(sm);
1351  }
1352  else
1353  {
1354  p->addTxQueue(hash);
1355  }
1356  }
1357 }
1358 
1359 //------------------------------------------------------------------------------
1360 
1361 void
1363 {
1364  std::lock_guard lock(mutex_);
1365  list_.erase(&child);
1366  if (list_.empty())
1367  cond_.notify_all();
1368 }
1369 
1370 void
1372 {
1373  // Calling list_[].second->stop() may cause list_ to be modified
1374  // (OverlayImpl::remove() may be called on this same thread). So
1375  // iterating directly over list_ to call child->stop() could lead to
1376  // undefined behavior.
1377  //
1378  // Therefore we copy all of the weak/shared ptrs out of list_ before we
1379  // start calling stop() on them. That guarantees OverlayImpl::remove()
1380  // won't be called until vector<> children leaves scope.
1382  {
1383  std::lock_guard lock(mutex_);
1384  if (!work_)
1385  return;
1386  work_ = std::nullopt;
1387 
1388  children.reserve(list_.size());
1389  for (auto const& element : list_)
1390  {
1391  children.emplace_back(element.second.lock());
1392  }
1393  } // lock released
1394 
1395  for (auto const& child : children)
1396  {
1397  if (child != nullptr)
1398  child->stop();
1399  }
1400 }
1401 
1402 void
1404 {
1405  auto const result = m_peerFinder->autoconnect();
1406  for (auto addr : result)
1407  connect(addr);
1408 }
1409 
1410 void
1412 {
1413  auto const result = m_peerFinder->buildEndpointsForPeers();
1414  for (auto const& e : result)
1415  {
1417  {
1418  std::lock_guard lock(mutex_);
1419  auto const iter = m_peers.find(e.first);
1420  if (iter != m_peers.end())
1421  peer = iter->second.lock();
1422  }
1423  if (peer)
1424  peer->sendEndpoints(e.second.begin(), e.second.end());
1425  }
1426 }
1427 
1428 void
1430 {
1431  for_each([](auto const& p) {
1432  if (p->txReduceRelayEnabled())
1433  p->sendTxQueue();
1434  });
1435 }
1436 
1439  PublicKey const& validator,
1440  bool squelch,
1441  uint32_t squelchDuration)
1442 {
1443  protocol::TMSquelch m;
1444  m.set_squelch(squelch);
1445  m.set_validatorpubkey(validator.data(), validator.size());
1446  if (squelch)
1447  m.set_squelchduration(squelchDuration);
1448  return std::make_shared<Message>(m, protocol::mtSQUELCH);
1449 }
1450 
1451 void
1452 OverlayImpl::unsquelch(PublicKey const& validator, Peer::id_t id) const
1453 {
1454  if (auto peer = findPeerByShortID(id);
1455  peer && app_.config().VP_REDUCE_RELAY_SQUELCH)
1456  {
1457  // optimize - multiple message with different
1458  // validator might be sent to the same peer
1459  peer->send(makeSquelchMessage(validator, false, 0));
1460  }
1461 }
1462 
1463 void
1465  PublicKey const& validator,
1466  Peer::id_t id,
1467  uint32_t squelchDuration) const
1468 {
1469  if (auto peer = findPeerByShortID(id);
1470  peer && app_.config().VP_REDUCE_RELAY_SQUELCH)
1471  {
1472  peer->send(makeSquelchMessage(validator, true, squelchDuration));
1473  }
1474 }
1475 
1476 void
1478  uint256 const& key,
1479  PublicKey const& validator,
1480  std::set<Peer::id_t>&& peers,
1481  protocol::MessageType type)
1482 {
1483  if (!strand_.running_in_this_thread())
1484  return post(
1485  strand_,
1486  [this, key, validator, peers = std::move(peers), type]() mutable {
1487  updateSlotAndSquelch(key, validator, std::move(peers), type);
1488  });
1489 
1490  for (auto id : peers)
1491  slots_.updateSlotAndSquelch(key, validator, id, type);
1492 }
1493 
1494 void
1496  uint256 const& key,
1497  PublicKey const& validator,
1498  Peer::id_t peer,
1499  protocol::MessageType type)
1500 {
1501  if (!strand_.running_in_this_thread())
1502  return post(strand_, [this, key, validator, peer, type]() {
1503  updateSlotAndSquelch(key, validator, peer, type);
1504  });
1505 
1506  slots_.updateSlotAndSquelch(key, validator, peer, type);
1507 }
1508 
1509 void
1511 {
1512  if (!strand_.running_in_this_thread())
1513  return post(strand_, std::bind(&OverlayImpl::deletePeer, this, id));
1514 
1515  slots_.deletePeer(id, true);
1516 }
1517 
1518 void
1520 {
1521  if (!strand_.running_in_this_thread())
1522  return post(strand_, std::bind(&OverlayImpl::deleteIdlePeers, this));
1523 
1524  slots_.deleteIdlePeers();
1525 }
1526 
1527 //------------------------------------------------------------------------------
1528 
1531 {
1533 
1534  {
1535  auto const& section = config.section("overlay");
1537 
1538  set(setup.ipLimit, "ip_limit", section);
1539  if (setup.ipLimit < 0)
1540  Throw<std::runtime_error>("Configured IP limit is invalid");
1541 
1542  std::string ip;
1543  set(ip, "public_ip", section);
1544  if (!ip.empty())
1545  {
1546  boost::system::error_code ec;
1547  setup.public_ip = beast::IP::Address::from_string(ip, ec);
1549  Throw<std::runtime_error>("Configured public IP is invalid");
1550  }
1551  }
1552 
1553  {
1554  auto const& section = config.section("crawl");
1555  auto const& values = section.values();
1556 
1557  if (values.size() > 1)
1558  {
1559  Throw<std::runtime_error>(
1560  "Configured [crawl] section is invalid, too many values");
1561  }
1562 
1563  bool crawlEnabled = true;
1564 
1565  // Only allow "0|1" as a value
1566  if (values.size() == 1)
1567  {
1568  try
1569  {
1570  crawlEnabled = boost::lexical_cast<bool>(values.front());
1571  }
1572  catch (boost::bad_lexical_cast const&)
1573  {
1574  Throw<std::runtime_error>(
1575  "Configured [crawl] section has invalid value: " +
1576  values.front());
1577  }
1578  }
1579 
1580  if (crawlEnabled)
1581  {
1582  if (get<bool>(section, "overlay", true))
1583  {
1585  }
1586  if (get<bool>(section, "server", true))
1587  {
1589  }
1590  if (get<bool>(section, "counts", false))
1591  {
1593  }
1594  if (get<bool>(section, "unl", true))
1595  {
1597  }
1598  }
1599  }
1600  {
1601  auto const& section = config.section("vl");
1602 
1603  set(setup.vlEnabled, "enabled", section);
1604  }
1605 
1606  try
1607  {
1608  auto id = config.legacy("network_id");
1609 
1610  if (!id.empty())
1611  {
1612  if (id == "main")
1613  id = "0";
1614 
1615  if (id == "testnet")
1616  id = "1";
1617 
1618  if (id == "devnet")
1619  id = "2";
1620 
1621  setup.networkID = beast::lexicalCastThrow<std::uint32_t>(id);
1622  }
1623  }
1624  catch (...)
1625  {
1626  Throw<std::runtime_error>(
1627  "Configured [network_id] section is invalid: must be a number "
1628  "or one of the strings 'main', 'testnet' or 'devnet'.");
1629  }
1630 
1631  return setup;
1632 }
1633 
1636  Application& app,
1637  Overlay::Setup const& setup,
1638  ServerHandler& serverHandler,
1640  Resolver& resolver,
1641  boost::asio::io_service& io_service,
1642  BasicConfig const& config,
1643  beast::insight::Collector::ptr const& collector)
1644 {
1645  return std::make_unique<OverlayImpl>(
1646  app,
1647  setup,
1648  serverHandler,
1650  resolver,
1651  io_service,
1652  config,
1653  collector);
1654 }
1655 
1656 } // namespace ripple
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:118
beast::PropertyStream::Source::name
std::string const & name() const
Returns the name of this source.
Definition: beast_PropertyStream.cpp:190
ripple::Resource::Manager::newInboundEndpoint
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
ripple::Resource::Manager::newOutboundEndpoint
virtual Consumer newOutboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by outbound IP address and port.
ripple::Application
Definition: Application.h:116
ripple::OverlayImpl::getServerCounts
Json::Value getServerCounts()
Returns information about the local server's performance counters.
Definition: OverlayImpl.cpp:878
ripple::OverlayImpl::journal_
const beast::Journal journal_
Definition: OverlayImpl.h:108
std::make_tuple
T make_tuple(T... args)
ripple::OverlayImpl::address_type
boost::asio::ip::address address_type
Definition: OverlayImpl.h:78
ripple::Application::cluster
virtual Cluster & cluster()=0
ripple::NetworkOPs::getServerInfo
virtual Json::Value getServerInfo(bool human, bool admin, bool counters)=0
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)
std::string
STL class.
std::shared_ptr< Collector >
ripple::makeSquelchMessage
std::shared_ptr< Message > makeSquelchMessage(PublicKey const &validator, bool squelch, uint32_t squelchDuration)
Definition: OverlayImpl.cpp:1438
ripple::Overlay::Setup::networkID
std::optional< std::uint32_t > networkID
Definition: Overlay.h:75
std::exception
STL class.
ripple::make_Overlay
std::unique_ptr< Overlay > make_Overlay(Application &app, Overlay::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)
Creates the implementation of Overlay.
Definition: OverlayImpl.cpp:1635
ripple::CrawlOptions::Disabled
@ Disabled
Definition: OverlayImpl.cpp:49
beast::Journal::trace
Stream trace() const
Severity stream access functions.
Definition: Journal.h:308
beast::PropertyStream::Map
Definition: PropertyStream.h:224
ripple::OverlayImpl::collect_metrics
void collect_metrics()
Definition: OverlayImpl.h:615
std::string_view
STL class.
ripple::InfoSub::Source::pubManifest
virtual void pubManifest(Manifest const &)=0
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::Manifest
Definition: Manifest.h:80
Json::arrayValue
@ arrayValue
array value (ordered list)
Definition: json_value.h:42
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:1477
ripple::OverlayImpl::autoConnect
void autoConnect()
Definition: OverlayImpl.cpp:1403
ripple::Application::validatorSites
virtual ValidatorSite & validatorSites()=0
ripple::HashPrefix::manifest
@ manifest
Manifest.
ripple::Overlay::Setup::crawlOptions
std::uint32_t crawlOptions
Definition: Overlay.h:74
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:767
ripple::OverlayImpl::stop
void stop() override
Definition: OverlayImpl.cpp:545
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::Timer::on_timer
void on_timer(error_code ec)
Definition: OverlayImpl.cpp:93
std::vector
STL class.
std::find_if
T find_if(T... args)
std::vector::size
T size(T... args)
ripple::Application::peerReservations
virtual PeerReservationTable & peerReservations()=0
ripple::OverlayImpl::next_id_
std::atomic< Peer::id_t > next_id_
Definition: OverlayImpl.h:116
ripple::base64_encode
std::string base64_encode(std::uint8_t const *data, std::size_t len)
Definition: base64.cpp:236
ripple::PublicKey::empty
bool empty() const noexcept
Definition: PublicKey.h:119
ripple::make_SSLContext
std::shared_ptr< boost::asio::ssl::context > make_SSLContext(std::string const &cipherList)
Create a self-signed SSL context that allows anonymous Diffie Hellman.
Definition: make_SSLContext.cpp:364
ripple::OverlayImpl::makePrefix
static std::string makePrefix(std::uint32_t id)
Definition: OverlayImpl.cpp:328
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:164
std::chrono::seconds
ripple::toBase58
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition: AccountID.cpp:104
std::set::emplace
T emplace(T... args)
ripple::OverlayImpl::csCV_
std::condition_variable csCV_
Definition: OverlayImpl.h:124
std::stringstream
STL class.
ripple::addValidatorManifest
void addValidatorManifest(soci::session &session, std::string const &serialized)
addValidatorManifest Saves the manifest of a validator to the database.
Definition: Wallet.cpp:115
ripple::OverlayImpl::strand_
boost::asio::io_service::strand strand_
Definition: OverlayImpl.h:102
std::shared_ptr::get
T get(T... args)
ripple::OverlayImpl::getServerInfo
Json::Value getServerInfo()
Returns information about the local server.
Definition: OverlayImpl.cpp:850
std::lock_guard
STL class.
ripple::Application::getShardStore
virtual NodeStore::DatabaseShard * getShardStore()=0
ripple::parseProtocolVersions
std::vector< ProtocolVersion > parseProtocolVersions(boost::beast::string_view const &value)
Parse a set of protocol versions.
Definition: ProtocolVersion.cpp:79
ripple::OverlayImpl::stopChildren
void stopChildren()
Definition: OverlayImpl.cpp:1371
ripple::makeSharedValue
std::optional< uint256 > makeSharedValue(stream_type &ssl, beast::Journal journal)
Computes a shared value based on the SSL connection state.
Definition: Handshake.cpp:147
ripple::Cluster::member
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
Definition: Cluster.cpp:39
ripple::stopwatch
Stopwatch & stopwatch()
Returns an instance of a wall clock.
Definition: chrono.h:120
std::setfill
T setfill(T... args)
ripple::OverlayImpl::broadcast
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
Definition: OverlayImpl.cpp:1217
ripple::PeerFinder::Manager::new_outbound_slot
virtual std::shared_ptr< Slot > new_outbound_slot(beast::IP::Endpoint const &remote_endpoint)=0
Create a new outbound slot with the specified remote endpoint.
ripple::OverlayImpl::connect
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Definition: OverlayImpl.cpp:383
ripple::OverlayImpl::json
Json::Value json() override
Return diagnostics on the status of all peers.
Definition: OverlayImpl.cpp:915
ripple::OverlayImpl::setup
Setup const & setup() const
Definition: OverlayImpl.h:176
ripple::OverlayImpl::timer_count_
int timer_count_
Definition: OverlayImpl.h:117
ripple::OverlayImpl::processValidatorList
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
Definition: OverlayImpl.cpp:963
beast::PropertyStream::Set
Definition: PropertyStream.h:296
std::shared_ptr::reset
T reset(T... args)
ripple::Application::getOPs
virtual NetworkOPs & getOPs()=0
ripple::Application::getWalletDB
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
ripple::OverlayImpl::m_traffic
TrafficCount m_traffic
Definition: OverlayImpl.h:112
ripple::OverlayImpl::processHealth
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
Definition: OverlayImpl.cpp:1031
ripple::OverlayImpl::setup_
Setup setup_
Definition: OverlayImpl.h:107
ripple::Section::values
std::vector< std::string > const & values() const
Returns all the values in the section.
Definition: BasicConfig.h:77
std::set::clear
T clear(T... args)
beast::IP::is_private
bool is_private(AddressV4 const &addr)
Returns true if the address is a private unroutable address.
Definition: IPAddressV4.cpp:29
ripple::send_always
Sends a message to all peers.
Definition: predicates.h:31
ripple::OverlayImpl::start
void start() override
Definition: OverlayImpl.cpp:464
ripple::PeerFinder::Config::makeConfig
static Config makeConfig(ripple::Config const &config, std::uint16_t port, bool validationPublicKey, int ipLimit)
Make PeerFinder::Config from configuration parameters.
Definition: PeerfinderConfig.cpp:78
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:1429
ripple::TrafficCount::category
category
Definition: TrafficCount.h:67
std::vector::push_back
T push_back(T... args)
beast::IPAddressConversion::from_asio
static IP::Endpoint from_asio(boost::asio::ip::address const &address)
Definition: IPAddressConversion.h:63
ripple::Tuning::checkIdlePeers
@ checkIdlePeers
How often we check for idle peers (seconds)
Definition: overlay/impl/Tuning.h:58
ripple::PeerFinder::Result::success
@ success
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:781
ripple::OverlayImpl::checkTracking
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
Definition: OverlayImpl.cpp:1183
beast::rfc2616::is_keep_alive
bool is_keep_alive(boost::beast::http::message< isRequest, Body, Fields > const &m)
Definition: rfc2616.h:386
ripple::setup_Overlay
Overlay::Setup setup_Overlay(BasicConfig const &config)
Definition: OverlayImpl.cpp:1530
ripple::OverlayImpl::csMutex_
std::mutex csMutex_
Definition: OverlayImpl.h:123
Json::Value::append
Value & append(const Value &value)
Append value to array at the end.
Definition: json_value.cpp:882
ripple::OverlayImpl::onManifests
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
Definition: OverlayImpl.cpp:618
ripple::Overlay::Setup::public_ip
beast::IP::Address public_ip
Definition: Overlay.h:72
ripple::OverlayImpl::manifestMessage_
std::shared_ptr< Message > manifestMessage_
Definition: OverlayImpl.h:134
ripple::DatabaseCon::checkoutDb
LockedSociSession checkoutDb()
Definition: DatabaseCon.h:178
ripple::OverlayImpl::resourceManager
Resource::Manager & resourceManager()
Definition: OverlayImpl.h:170
Json::objectValue
@ objectValue
object value (collection of name/value pairs).
Definition: json_value.h:43
ripple::ServerHandler
Definition: ServerHandler.h:47
beast::PropertyStream::Source::add
void add(Source &source)
Add a child source.
Definition: beast_PropertyStream.cpp:196
ripple::PublicKey
A public key.
Definition: PublicKey.h:61
ripple::OverlayImpl::getOverlayInfo
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
Definition: OverlayImpl.cpp:794
ripple::OverlayImpl::io_service_
boost::asio::io_service & io_service_
Definition: OverlayImpl.h:100
ripple::Application::config
virtual Config & config()=0
ripple::ValidatorSite::getJson
Json::Value getJson() const
Return JSON representation of configured validator sites.
Definition: ValidatorSite.cpp:667
ripple::Config::IPS_FIXED
std::vector< std::string > IPS_FIXED
Definition: Config.h:156
ripple::Config::standalone
bool standalone() const
Definition: Config.h:346
std::unique_lock
STL class.
ripple::Resolver
Definition: Resolver.h:30
ripple::OverlayImpl::slots_
reduce_relay::Slots< UptimeClock > slots_
Definition: OverlayImpl.h:128
ripple::Application::nodeIdentity
virtual std::pair< PublicKey, SecretKey > const & nodeIdentity()=0
ripple::OverlayImpl::m_stats
Stats m_stats
Definition: OverlayImpl.h:610
std::to_string
T to_string(T... args)
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:313
ripple::OverlayImpl::getUnlInfo
Json::Value getUnlInfo()
Returns information about the local server's UNL.
Definition: OverlayImpl.cpp:884
ripple::ValidatorList::listed
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
Definition: ValidatorList.cpp:1350
ripple::default_prng
beast::xor_shift_engine & default_prng()
Return the default random engine.
Definition: ripple/basics/random.h:65
beast::Journal::info
Stream info() const
Definition: Journal.h:320
std::set::erase
T erase(T... args)
ripple::ValidatorList::getAvailable
std::optional< Json::Value > getAvailable(boost::beast::string_view const &pubKey, std::optional< std::uint32_t > forceVersion={})
Returns the current valid list for the given publisher key, if available, as a Json object.
Definition: ValidatorList.cpp:1679
ripple::BasicConfig::legacy
void legacy(std::string const &section, std::string value)
Set a value that is not a key/value pair.
Definition: BasicConfig.cpp:164
ripple::Application::logs
virtual Logs & logs()=0
ripple::ManifestCache::for_each_manifest
void for_each_manifest(Function &&f) const
Invokes the callback once for every populated manifest.
Definition: Manifest.h:401
ripple::OverlayImpl::app_
Application & app_
Definition: OverlayImpl.h:99
ripple::CrawlOptions::ServerCounts
@ ServerCounts
Definition: OverlayImpl.cpp:52
ripple::OverlayImpl::m_peerFinder
std::unique_ptr< PeerFinder::Manager > m_peerFinder
Definition: OverlayImpl.h:111
Json::Value::isMember
bool isMember(const char *key) const
Return true if the object has a member named key.
Definition: json_value.cpp:932
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::OverlayImpl::serverHandler_
ServerHandler & serverHandler_
Definition: OverlayImpl.h:109
std::uint32_t
std::condition_variable_any::wait
T wait(T... args)
ripple::OverlayImpl::TrafficGauges
Definition: OverlayImpl.h:574
ripple::OverlayImpl::Child::Child
Child(OverlayImpl &overlay)
Definition: OverlayImpl.cpp:59
ripple::HashRouter::shouldRelay
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
Definition: HashRouter.cpp:118
ripple::OverlayImpl::getActivePeers
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Definition: OverlayImpl.cpp:1137
ripple::CrawlOptions::Unl
@ Unl
Definition: OverlayImpl.cpp:53
beast::rfc2616::split_commas
Result split_commas(FwdIt first, FwdIt last)
Definition: rfc2616.h:199
ripple::Application::getValidationPublicKey
virtual PublicKey const & getValidationPublicKey() const =0
ripple::OverlayImpl::Timer::async_wait
void async_wait()
Definition: OverlayImpl.cpp:85
ripple::Handoff::moved
bool moved
Definition: Handoff.h:41
std::condition_variable::wait_for
T wait_for(T... args)
ripple::CrawlOptions::Overlay
@ Overlay
Definition: OverlayImpl.cpp:50
ripple::OverlayImpl::deleteIdlePeers
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
Definition: OverlayImpl.cpp:1519
ripple::Application::validators
virtual ValidatorList & validators()=0
ripple::OverlayImpl::processRequest
bool processRequest(http_request_type const &req, Handoff &handoff)
Handles non-peer protocol requests.
Definition: OverlayImpl.cpp:1129
ripple::OverlayImpl::manifestListSeq_
std::optional< std::uint32_t > manifestListSeq_
Definition: OverlayImpl.h:136
ripple::ManifestDisposition::accepted
@ accepted
Manifest is valid.
ripple::Resource::Manager
Tracks load and resource consumption.
Definition: ResourceManager.h:36
std::ostringstream
STL class.
ripple::BuildInfo::getFullVersionString
std::string const & getFullVersionString()
Full server version string.
Definition: BuildInfo.cpp:78
ripple::OverlayImpl::deletePeer
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Definition: OverlayImpl.cpp:1510
ripple::getCountsJson
Json::Value getCountsJson(Application &app, int minObjectCount)
Definition: GetCounts.cpp:65
ripple::OverlayImpl::Child::~Child
virtual ~Child()
Definition: OverlayImpl.cpp:63
ripple::OverlayImpl::m_resourceManager
Resource::Manager & m_resourceManager
Definition: OverlayImpl.h:110
std::vector::emplace_back
T emplace_back(T... args)
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:1224
ripple::metrics::TxMetrics::addMetrics
void addMetrics(protocol::MessageType type, std::uint32_t val)
Add protocol message metrics.
Definition: TxMetrics.cpp:30
ripple::Overlay::Setup::ipLimit
int ipLimit
Definition: Overlay.h:73
ripple::Application::journal
virtual beast::Journal journal(std::string const &name)=0
ripple::Application::validatorManifests
virtual ManifestCache & validatorManifests()=0
ripple::OverlayImpl::getManifestsMessage
std::shared_ptr< Message > getManifestsMessage()
Definition: OverlayImpl.cpp:1269
Json::Value::removeMember
Value removeMember(const char *key)
Remove and return the named member.
Definition: json_value.cpp:907
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:680
ripple::Overlay::Setup::vlEnabled
bool vlEnabled
Definition: Overlay.h:76
ripple::Config::TX_REDUCE_RELAY_MIN_PEERS
std::size_t TX_REDUCE_RELAY_MIN_PEERS
Definition: Config.h:280
ripple::OverlayImpl::remove
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Definition: OverlayImpl.cpp:455
ripple::Overlay
Manages the set of connected peers.
Definition: Overlay.h:51
ripple::Config::TX_REDUCE_RELAY_METRICS
bool TX_REDUCE_RELAY_METRICS
Definition: Config.h:277
std
STL namespace.
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:587
ripple::OverlayImpl::onPeerDeactivate
void onPeerDeactivate(Peer::id_t id)
Definition: OverlayImpl.cpp:611
Json::nullValue
@ nullValue
'null' value
Definition: json_value.h:36
ripple::OverlayImpl::list_
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
Definition: OverlayImpl.h:106
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:70
std::set::count
T count(T... args)
ripple::OverlayImpl::squelch
void squelch(PublicKey const &validator, Peer::id_t const id, std::uint32_t squelchDuration) const override
Squelch handler.
Definition: OverlayImpl.cpp:1464
beast::WrappedSink
Wraps a Journal::Sink to prefix its output with a string.
Definition: WrappedSink.h:33
std::vector::empty
T empty(T... args)
ripple::Handoff
Used to indicate the result of a server connection handoff.
Definition: Handoff.h:37
ripple::TokenType::NodePublic
@ NodePublic
ripple::Overlay::Setup
Definition: Overlay.h:67
ripple::OverlayImpl::Timer::stop
void stop() override
Definition: OverlayImpl.cpp:76
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:1202
ripple::ValidatorList::getJson
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
Definition: ValidatorList.cpp:1508
ripple::PeerReservationTable::contains
bool contains(PublicKey const &nodeId)
Definition: PeerReservationTable.h:89
std::stringstream::str
T str(T... args)
beast::Journal::debug
Stream debug() const
Definition: Journal.h:314
ripple::Config::IPS
std::vector< std::string > IPS
Definition: Config.h:153
ripple::OverlayImpl::txMetrics_
metrics::TxMetrics txMetrics_
Definition: OverlayImpl.h:131
std::size_t
ripple::to_string
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
Definition: app/misc/impl/Manifest.cpp:41
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:336
ripple::Config::TX_RELAY_PERCENTAGE
std::size_t TX_RELAY_PERCENTAGE
Definition: Config.h:283
beast::IP::Endpoint
A version-independent IP address and port combination.
Definition: IPEndpoint.h:38
ripple::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition: strHex.h:30
ripple::OverlayImpl::timer_
std::weak_ptr< Timer > timer_
Definition: OverlayImpl.h:105
ripple::Overlay::Setup::context
std::shared_ptr< boost::asio::ssl::context > context
Definition: Overlay.h:71
std::unordered_map::end
T end(T... args)
ripple::Handoff::response
std::shared_ptr< Writer > response
Definition: Handoff.h:47
beast::IPAddressConversion::to_asio_endpoint
static boost::asio::ip::tcp::endpoint to_asio_endpoint(IP::Endpoint const &address)
Definition: IPAddressConversion.h:78
ripple::deserializeManifest
std::optional< Manifest > deserializeManifest(Slice s, beast::Journal journal)
Constructs Manifest from serialized string.
Definition: app/misc/impl/Manifest.cpp:53
ripple::Config::TX_REDUCE_RELAY_ENABLE
bool TX_REDUCE_RELAY_ENABLE
Definition: Config.h:270
ripple::PeerFinder::Config
PeerFinder configuration settings.
Definition: PeerfinderManager.h:40
std::setw
T setw(T... args)
ripple::verifyHandshake
PublicKey verifyHandshake(boost::beast::http::fields const &headers, ripple::uint256 const &sharedValue, std::optional< std::uint32_t > networkID, beast::IP::Address public_ip, beast::IP::Address remote, Application &app)
Validate header fields necessary for upgrading the link to the peer protocol.
Definition: Handshake.cpp:228
ripple::OverlayImpl
Definition: OverlayImpl.h:58
ripple::CrawlOptions::ServerInfo
@ ServerInfo
Definition: OverlayImpl.cpp:51
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:1190
ripple::ServerHandler::setup
void setup(Setup const &setup, beast::Journal journal)
Definition: ServerHandler.cpp:131
ripple::OverlayImpl::reportTraffic
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
Definition: OverlayImpl.cpp:671
ripple::TrafficCount::addCount
void addCount(category cat, bool inbound, int bytes)
Account for traffic associated with the given category.
Definition: TrafficCount.h:173
ripple::OverlayImpl::Child
Definition: OverlayImpl.h:61
ripple::http_request_type
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handshake.h:47
std::unique_ptr< stream_type >
std::shuffle
T shuffle(T... args)
ripple::ManifestCache::applyManifest
ManifestDisposition applyManifest(Manifest m)
Add manifest to cache.
Definition: app/misc/impl/Manifest.cpp:363
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:363
ripple::OverlayImpl::m_peers
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
Definition: OverlayImpl.h:113
ripple::Resolver::resolve
void resolve(std::vector< std::string > const &names, Handler handler)
resolve all hostnames on the list
Definition: Resolver.h:57
std::unordered_map
STL class.
ripple::OverlayImpl::isPeerUpgrade
static bool isPeerUpgrade(http_request_type const &request)
Definition: OverlayImpl.cpp:319
ripple::OverlayImpl::add_active
void add_active(std::shared_ptr< PeerImp > const &peer)
Definition: OverlayImpl.cpp:421
ripple::negotiateProtocolVersion
std::optional< ProtocolVersion > negotiateProtocolVersion(std::vector< ProtocolVersion > const &versions)
Given a list of supported protocol versions, choose the one we prefer.
Definition: ProtocolVersion.cpp:126
ripple::OverlayImpl::error_code
boost::system::error_code error_code
Definition: OverlayImpl.h:80
std::condition_variable::notify_all
T notify_all(T... args)
ripple::OverlayImpl::onWrite
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
Definition: OverlayImpl.cpp:562
std::set
STL class.
ripple::Application::getHashRouter
virtual HashRouter & getHashRouter()=0
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:1411
ripple::OverlayImpl::for_each
void for_each(UnaryFunc &&f) const
Definition: OverlayImpl.h:281
std::exception::what
T what(T... args)
ripple::OverlayImpl::unsquelch
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
Definition: OverlayImpl.cpp:1452
ripple::HashPrefix::shardInfo
@ shardInfo
shard info for signing
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::BasicConfig::section
Section & section(std::string const &name)
Returns the section with the given name.
Definition: BasicConfig.cpp:127
ripple::OverlayImpl::limit
int limit() override
Returns the maximum number of peers we are configured to allow.
Definition: OverlayImpl.cpp:788
ripple::OverlayImpl::processCrawl
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
Definition: OverlayImpl.cpp:926
ripple::OverlayImpl::endpoint_type
boost::asio::ip::tcp::endpoint endpoint_type
Definition: OverlayImpl.h:79
ripple::Handoff::keep_alive
bool keep_alive
Definition: Handoff.h:44
ripple::ManifestCache::sequence
std::uint32_t sequence() const
A monotonically increasing number used to detect new manifests.
Definition: Manifest.h:254
std::chrono