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>
42 #include <boost/algorithm/string/predicate.hpp>
43 #include <boost/utility/in_place_factory.hpp>
47 namespace CrawlOptions {
65 overlay_.remove(*
this);
97 if (ec && ec != boost::asio::error::operation_aborted)
99 JLOG(overlay_.journal_.error()) <<
"on_timer: " << ec.message();
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();
111 overlay_.deleteIdlePeers();
124 boost::asio::io_service& io_service,
138 app_.journal(
"PeerFinder"),
144 ,
slots_(app.logs(), *this)
148 [counts =
m_traffic.getCounts(), collector]() {
152 for (
size_t i = 0; i < counts.size(); ++i)
179 handoff.
moved =
true;
181 JLOG(journal.
debug()) <<
"Peer connection upgrade from " << remote_endpoint;
184 auto const local_endpoint(
185 stream_ptr->next_layer().socket().local_endpoint(ec));
188 JLOG(journal.
debug()) << remote_endpoint <<
" failed: " << ec.message();
194 if (consumer.disconnect(journal))
204 handoff.
moved =
false;
213 return boost::iequals(s,
"peer");
216 handoff.
moved =
false;
225 if (!negotiatedVersion)
228 handoff.
moved =
false;
232 remote_endpoint.address(),
233 "Unable to agree on a protocol version");
242 handoff.
moved =
false;
246 remote_endpoint.address(),
247 "Incorrect security cookie");
259 remote_endpoint.address(),
265 bool const reserved =
273 JLOG(journal.
debug())
274 <<
"Peer " << remote_endpoint <<
" redirected, slots full";
275 handoff.
moved =
false;
277 slot, request, remote_endpoint.address());
283 auto const ih = std::make_shared<InboundHandoff>(
291 std::move(stream_ptr),
295 list_.emplace(ih.get(), ih);
299 handoff.
moved =
true;
304 JLOG(journal.
debug()) <<
"Peer " << remote_endpoint
305 <<
" fails handshake (" << e.
what() <<
")";
308 handoff.
moved =
false;
310 slot, request, remote_endpoint.address(), e.
what());
324 return !versions.empty();
341 boost::beast::http::response<json_body> msg;
342 msg.version(request.version());
343 msg.result(boost::beast::http::status::service_unavailable);
347 ostr << remote_address;
348 msg.insert(
"Remote-Address", ostr.
str());
350 msg.insert(
"Content-Type",
"application/json");
351 msg.insert(boost::beast::http::field::connection,
"close");
356 ips.
append(_.address.to_string());
358 msg.prepare_payload();
359 return std::make_shared<SimpleWriter>(msg);
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 +
")");
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);
390 JLOG(
journal_.
info()) <<
"Over resource limit: " << remote_endpoint;
397 JLOG(
journal_.
debug()) <<
"Connect: No slot for " << remote_endpoint;
401 auto const p = std::make_shared<ConnectAttempt>(
413 list_.emplace(p.get(), p);
426 auto const result =
m_peers.emplace(peer->slot(), peer);
427 assert(result.second);
432 auto const result =
ids_.emplace(
433 std::piecewise_construct,
436 assert(result.second);
442 JLOG(
journal_.
debug()) <<
"activated " << peer->getRemoteAddress() <<
" ("
458 auto const iter =
m_peers.find(slot);
482 if (bootstrapIps.empty())
485 bootstrapIps.
push_back(
"r.ripple.com 51235");
488 bootstrapIps.
push_back(
"zaphod.alloy.ee 51235");
491 bootstrapIps.push_back(
"sahyadri.isrdc.in 51235");
501 for (
auto const& addr : addresses)
503 if (addr.port() == 0)
525 for (
auto& addr : addresses)
527 if (addr.port() == 0)
537 auto const timer = std::make_shared<Timer>(*
this);
539 list_.emplace(timer.get(), timer);
566 for (
auto const& i : stats)
571 item[
"category"] = i.name;
592 auto const result(
ids_.emplace(
593 std::piecewise_construct,
596 assert(result.second);
600 JLOG(
journal_.
debug()) <<
"activated " << peer->getRemoteAddress() <<
" ("
622 auto const n = m->list_size();
623 auto const& journal = from->pjournal();
625 protocol::TMManifests
relay;
629 auto& s = m->list().Get(i).stobject();
633 auto const serialized = mo->serialized;
640 relay.add_list()->set_stobject(s);
659 JLOG(journal.debug())
660 <<
"Malformed manifest #" << i + 1 <<
": " <<
strHex(s);
665 if (!
relay.list().empty())
666 for_each([m2 = std::make_shared<Message>(
relay, protocol::mtMANIFESTS)](
689 if (includePublicKey)
690 jv[jss::public_key] =
693 auto const shardInfo{shardStore->getShardInfo()};
695 jv[jss::complete_shards] =
shardInfo->finalizedToString();
697 jv[jss::incomplete_shards] =
shardInfo->incompleteToString();
700 if (relays == 0 ||
size() == 0)
704 protocol::TMGetPeerShardInfoV2 tmGPS;
705 tmGPS.set_relays(relays);
714 for (
auto const&
id :
ids_)
720 tmGPS, protocol::mtGET_PEER_SHARD_INFO_V2)));
732 auto const psi{peer->getPeerShardInfos()};
733 for (
auto const& [publicKey,
shardInfo] : psi)
735 auto const it{peerShardInfo.
find(publicKey)};
736 if (it == peerShardInfo.
end())
738 else if (
shardInfo.msgTimestamp() > it->second.msgTimestamp())
744 if (!peerShardInfo.
empty())
747 for (
auto const& [publicKey,
shardInfo] : peerShardInfo)
750 if (includePublicKey)
752 pv[jss::public_key] =
757 pv[jss::complete_shards] =
shardInfo.finalizedToString();
759 pv[jss::incomplete_shards] =
shardInfo.incompleteToString();
803 sp->getNodePublic().data(), sp->getNodePublic().size());
804 pv[jss::type] = sp->slot()->inbound() ?
"in" :
"out";
806 duration_cast<seconds>(sp->uptime()).count());
809 pv[jss::ip] = sp->getRemoteAddress().address().to_string();
810 if (sp->slot()->inbound())
812 if (
auto port = sp->slot()->listening_port())
813 pv[jss::port] = *port;
822 auto version{sp->getVersion()};
823 if (!version.empty())
825 pv[jss::version] = version;
829 sp->ledgerRange(minSeq, maxSeq);
830 if (minSeq != 0 || maxSeq != 0)
831 pv[jss::complete_ledgers] =
834 auto const peerShardInfos{sp->getPeerShardInfos()};
835 auto const it{peerShardInfos.find(sp->getNodePublic())};
836 if (it != peerShardInfos.end())
840 pv[jss::complete_shards] =
shardInfo.finalizedToString();
842 pv[jss::incomplete_shards] =
shardInfo.incompleteToString();
852 bool const humanReadable =
false;
853 bool const admin =
false;
854 bool const counters =
false;
861 server_info.
removeMember(jss::load_factor_fee_escalation);
865 if (server_info.
isMember(jss::validated_ledger))
867 Json::Value& validated_ledger = server_info[jss::validated_ledger];
888 if (validators.
isMember(jss::publisher_lists))
890 Json::Value& publisher_lists = validators[jss::publisher_lists];
892 for (
auto& publisher : publisher_lists)
904 if (validatorSites.
isMember(jss::validator_sites))
906 validators[jss::validator_sites] =
907 std::move(validatorSites[jss::validator_sites]);
928 if (req.target() !=
"/crawl" ||
932 boost::beast::http::response<json_body> msg;
933 msg.version(req.version());
934 msg.result(boost::beast::http::status::ok);
936 msg.insert(
"Content-Type",
"application/json");
937 msg.insert(
"Connection",
"close");
957 msg.prepare_payload();
958 handoff.
response = std::make_shared<SimpleWriter>(msg);
976 boost::beast::http::response<json_body> msg;
977 msg.version(req.version());
979 msg.insert(
"Content-Type",
"application/json");
980 msg.insert(
"Connection",
"close");
982 auto fail = [&msg, &handoff](
auto status) {
984 msg.insert(
"Content-Length",
"0");
988 msg.prepare_payload();
989 handoff.
response = std::make_shared<SimpleWriter>(msg);
993 auto key = req.target().substr(prefix.size());
995 if (
auto slash = key.find(
'/'); slash != boost::string_view::npos)
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);
1004 return fail(boost::beast::http::status::bad_request);
1012 return fail(boost::beast::http::status::not_found);
1016 return fail(boost::beast::http::status::bad_request);
1020 msg.result(boost::beast::http::status::ok);
1024 msg.prepare_payload();
1025 handoff.
response = std::make_shared<SimpleWriter>(msg);
1033 if (req.target() !=
"/health")
1035 boost::beast::http::response<json_body> msg;
1036 msg.version(req.version());
1038 msg.insert(
"Content-Type",
"application/json");
1039 msg.insert(
"Connection",
"close");
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();
1055 enum { healthy, warning, critical };
1056 int health = healthy;
1057 auto set_health = [&health](
int state) {
1063 if (last_validated_ledger_age >= 7 || last_validated_ledger_age < 0)
1065 msg.body()[jss::info][jss::validated_ledger] =
1066 last_validated_ledger_age;
1067 if (last_validated_ledger_age < 20)
1068 set_health(warning);
1070 set_health(critical);
1073 if (amendment_blocked)
1075 msg.body()[jss::info][jss::amendment_blocked] =
true;
1076 set_health(critical);
1079 if (number_peers <= 7)
1081 msg.body()[jss::info][jss::peers] = number_peers;
1082 if (number_peers != 0)
1083 set_health(warning);
1085 set_health(critical);
1088 if (!(server_state ==
"full" || server_state ==
"validating" ||
1089 server_state ==
"proposing"))
1091 msg.body()[jss::info][jss::server_state] = server_state;
1092 if (server_state ==
"syncing" || server_state ==
"tracking" ||
1093 server_state ==
"connected")
1095 set_health(warning);
1098 set_health(critical);
1101 if (load_factor > 100)
1103 msg.body()[jss::info][jss::load_factor] = load_factor;
1104 if (load_factor < 1000)
1105 set_health(warning);
1107 set_health(critical);
1113 msg.result(boost::beast::http::status::ok);
1116 msg.result(boost::beast::http::status::service_unavailable);
1119 msg.result(boost::beast::http::status::internal_server_error);
1123 msg.prepare_payload();
1124 handoff.
response = std::make_shared<SimpleWriter>(msg);
1159 active =
ids_.size();
1160 disabled = enabledInSkip = 0;
1163 for (
auto& [
id, w] :
ids_)
1165 if (
auto p = w.lock())
1167 bool const reduceRelayEnabled = p->txReduceRelayEnabled();
1169 if (!reduceRelayEnabled)
1172 if (toSkip.
count(
id) == 0)
1174 else if (reduceRelayEnabled)
1193 auto const iter =
ids_.find(
id);
1194 if (iter !=
ids_.end())
1195 return iter->second.lock();
1205 for (
auto const& e :
ids_)
1207 if (
auto peer = e.second.lock())
1209 if (peer->getNodePublic() == pubKey)
1219 auto const sm = std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER);
1225 protocol::TMProposeSet& m,
1232 std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER, validator);
1234 if (toSkip->find(p->id()) == toSkip->end())
1245 auto const sm = std::make_shared<Message>(m, protocol::mtVALIDATION);
1251 protocol::TMValidation& m,
1258 std::make_shared<Message>(m, protocol::mtVALIDATION, validator);
1260 if (toSkip->find(p->id()) == toSkip->end())
1276 protocol::TMManifests tm;
1279 [&tm](
std::size_t s) { tm.mutable_list()->Reserve(s); },
1281 tm.add_list()->set_stobject(
1283 hr.addSuppression(
manifest.hash());
1288 if (tm.list_size() != 0)
1290 std::make_shared<Message>(tm, protocol::mtMANIFESTS);
1301 protocol::TMTransaction& m,
1304 auto const sm = std::make_shared<Message>(m, protocol::mtTRANSACTION);
1310 auto peers =
getActivePeers(toSkip, total, disabled, enabledInSkip);
1315 for (
auto const& p : peers)
1331 if (enabledTarget > enabledInSkip)
1334 JLOG(
journal_.
trace()) <<
"relaying tx, total peers " << peers.size()
1335 <<
" selected " << enabledTarget <<
" skip "
1336 << toSkip.
size() <<
" disabled " << disabled;
1340 for (
auto const& p : peers)
1343 if (!p->txReduceRelayEnabled())
1347 else if (enabledAndRelayed < enabledTarget)
1349 enabledAndRelayed++;
1354 p->addTxQueue(hash);
1365 list_.erase(&child);
1386 work_ = std::nullopt;
1389 for (
auto const& element :
list_)
1395 for (
auto const& child : children)
1397 if (child !=
nullptr)
1406 for (
auto addr : result)
1413 auto const result =
m_peerFinder->buildEndpointsForPeers();
1414 for (
auto const& e : result)
1419 auto const iter =
m_peers.find(e.first);
1421 peer = iter->second.lock();
1424 peer->sendEndpoints(e.second.begin(), e.second.end());
1432 if (p->txReduceRelayEnabled())
1441 uint32_t squelchDuration)
1443 protocol::TMSquelch m;
1445 m.set_validatorpubkey(validator.data(), validator.size());
1447 m.set_squelchduration(squelchDuration);
1448 return std::make_shared<Message>(m, protocol::mtSQUELCH);
1455 peer &&
app_.
config().VP_REDUCE_RELAY_SQUELCH)
1467 uint32_t squelchDuration)
const
1470 peer &&
app_.
config().VP_REDUCE_RELAY_SQUELCH)
1481 protocol::MessageType type)
1483 if (!
strand_.running_in_this_thread())
1486 [
this, key, validator, peers = std::move(peers), type]()
mutable {
1490 for (
auto id : peers)
1491 slots_.updateSlotAndSquelch(key, validator,
id, type);
1499 protocol::MessageType type)
1501 if (!
strand_.running_in_this_thread())
1502 return post(
strand_, [
this, key, validator, peer, type]() {
1506 slots_.updateSlotAndSquelch(key, validator, peer, type);
1512 if (!
strand_.running_in_this_thread())
1515 slots_.deletePeer(
id,
true);
1521 if (!
strand_.running_in_this_thread())
1524 slots_.deleteIdlePeers();
1535 auto const& section = config.
section(
"overlay");
1540 Throw<std::runtime_error>(
"Configured IP limit is invalid");
1543 set(ip,
"public_ip", section);
1546 boost::system::error_code ec;
1549 Throw<std::runtime_error>(
"Configured public IP is invalid");
1554 auto const& section = config.
section(
"crawl");
1555 auto const& values = section.
values();
1557 if (values.size() > 1)
1559 Throw<std::runtime_error>(
1560 "Configured [crawl] section is invalid, too many values");
1563 bool crawlEnabled =
true;
1566 if (values.size() == 1)
1570 crawlEnabled = boost::lexical_cast<bool>(values.front());
1572 catch (boost::bad_lexical_cast
const&)
1574 Throw<std::runtime_error>(
1575 "Configured [crawl] section has invalid value: " +
1582 if (get<bool>(section,
"overlay",
true))
1586 if (get<bool>(section,
"server",
true))
1590 if (get<bool>(section,
"counts",
false))
1594 if (get<bool>(section,
"unl",
true))
1601 auto const& section = config.
section(
"vl");
1608 auto id = config.
legacy(
"network_id");
1615 if (
id ==
"testnet")
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'.");
1641 boost::asio::io_service& io_service,
1645 return std::make_unique<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)
std::string const & name() const
Returns the name of this source.
virtual Consumer newInboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by inbound IP address or the forwarded IP if proxied.
virtual Consumer newOutboundEndpoint(beast::IP::Endpoint const &address)=0
Create a new endpoint keyed by outbound IP address and port.
Json::Value getServerCounts()
Returns information about the local server's performance counters.
const beast::Journal journal_
boost::asio::ip::address address_type
virtual Cluster & cluster()=0
virtual Json::Value getServerInfo(bool human, bool admin, bool counters)=0
auto const & getCounts() const
An up-to-date copy of all the counters.
std::shared_ptr< Message > makeSquelchMessage(PublicKey const &validator, bool squelch, uint32_t squelchDuration)
std::optional< std::uint32_t > networkID
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.
Stream trace() const
Severity stream access functions.
virtual void pubManifest(Manifest const &)=0
static bool is_upgrade(boost::beast::http::header< true, Fields > const &req)
hash_map< Peer::id_t, std::weak_ptr< PeerImp > > ids_
@ arrayValue
array value (ordered list)
void updateSlotAndSquelch(uint256 const &key, PublicKey const &validator, std::set< Peer::id_t > &&peers, protocol::MessageType type)
Updates message count for validator/peer.
virtual ValidatorSite & validatorSites()=0
std::uint32_t crawlOptions
void endOfPeerChain(std::uint32_t id)
Called when the reply from the last peer in a peer chain is received.
std::set< std::uint32_t > csIDs_
std::recursive_mutex mutex_
void on_timer(error_code ec)
virtual PeerReservationTable & peerReservations()=0
std::atomic< Peer::id_t > next_id_
std::string base64_encode(std::uint8_t const *data, std::size_t len)
bool empty() const noexcept
std::shared_ptr< boost::asio::ssl::context > make_SSLContext(std::string const &cipherList)
Create a self-signed SSL context that allows anonymous Diffie Hellman.
static std::string makePrefix(std::uint32_t id)
Handoff onHandoff(std::unique_ptr< stream_type > &&bundle, http_request_type &&request, endpoint_type remote_endpoint) override
Conditionally accept an incoming HTTP request.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
std::condition_variable csCV_
void addValidatorManifest(soci::session &session, std::string const &serialized)
addValidatorManifest Saves the manifest of a validator to the database.
boost::asio::io_service::strand strand_
Json::Value getServerInfo()
Returns information about the local server.
virtual NodeStore::DatabaseShard * getShardStore()=0
std::vector< ProtocolVersion > parseProtocolVersions(boost::beast::string_view const &value)
Parse a set of protocol versions.
std::optional< uint256 > makeSharedValue(stream_type &ssl, beast::Journal journal)
Computes a shared value based on the SSL connection state.
std::optional< std::string > member(PublicKey const &node) const
Determines whether a node belongs in the cluster.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
void broadcast(protocol::TMProposeSet &m) override
Broadcast a proposal.
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.
void connect(beast::IP::Endpoint const &remote_endpoint) override
Establish a peer connection to the specified endpoint.
Json::Value json() override
Return diagnostics on the status of all peers.
Setup const & setup() const
bool processValidatorList(http_request_type const &req, Handoff &handoff)
Handles validator list requests.
virtual NetworkOPs & getOPs()=0
virtual DatabaseCon & getWalletDB()=0
Retrieve the "wallet database".
bool processHealth(http_request_type const &req, Handoff &handoff)
Handles health requests.
std::vector< std::string > const & values() const
Returns all the values in the section.
bool is_private(AddressV4 const &addr)
Returns true if the address is a private unroutable address.
Sends a message to all peers.
static Config makeConfig(ripple::Config const &config, std::uint16_t port, bool validationPublicKey, int ipLimit)
Make PeerFinder::Config from configuration parameters.
std::condition_variable_any cond_
void sendTxQueue()
Send once a second transactions' hashes aggregated by peers.
static IP::Endpoint from_asio(boost::asio::ip::address const &address)
@ checkIdlePeers
How often we check for idle peers (seconds)
PeerFinder::Manager & peerFinder()
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...
void checkTracking(std::uint32_t) override
Calls the checkTracking function on each peer.
bool is_keep_alive(boost::beast::http::message< isRequest, Body, Fields > const &m)
Overlay::Setup setup_Overlay(BasicConfig const &config)
Value & append(const Value &value)
Append value to array at the end.
void onManifests(std::shared_ptr< protocol::TMManifests > const &m, std::shared_ptr< PeerImp > const &from)
beast::IP::Address public_ip
std::shared_ptr< Message > manifestMessage_
LockedSociSession checkoutDb()
Resource::Manager & resourceManager()
@ objectValue
object value (collection of name/value pairs).
void add(Source &source)
Add a child source.
Json::Value getOverlayInfo()
Returns information about peers on the overlay network.
boost::asio::io_service & io_service_
virtual Config & config()=0
Json::Value getJson() const
Return JSON representation of configured validator sites.
std::vector< std::string > IPS_FIXED
reduce_relay::Slots< UptimeClock > slots_
virtual std::pair< PublicKey, SecretKey > const & nodeIdentity()=0
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
Json::Value getUnlInfo()
Returns information about the local server's UNL.
bool listed(PublicKey const &identity) const
Returns true if public key is included on any lists.
beast::xor_shift_engine & default_prng()
Return the default random engine.
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.
void legacy(std::string const §ion, std::string value)
Set a value that is not a key/value pair.
void for_each_manifest(Function &&f) const
Invokes the callback once for every populated manifest.
std::unique_ptr< PeerFinder::Manager > m_peerFinder
bool isMember(const char *key) const
Return true if the object has a member named key.
A generic endpoint for log messages.
ServerHandler & serverHandler_
Child(OverlayImpl &overlay)
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
PeerSequence getActivePeers() const override
Returns a sequence representing the current list of peers.
Result split_commas(FwdIt first, FwdIt last)
virtual PublicKey const & getValidationPublicKey() const =0
void deleteIdlePeers()
Check if peers stopped relaying messages and if slots stopped receiving messages from the validator.
virtual ValidatorList & validators()=0
bool processRequest(http_request_type const &req, Handoff &handoff)
Handles non-peer protocol requests.
std::optional< std::uint32_t > manifestListSeq_
@ accepted
Manifest is valid.
Tracks load and resource consumption.
std::string const & getFullVersionString()
Full server version string.
void deletePeer(Peer::id_t id)
Called when the peer is deleted.
Json::Value getCountsJson(Application &app, int minObjectCount)
Resource::Manager & m_resourceManager
T emplace_back(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator) override
Relay a proposal.
void addMetrics(protocol::MessageType type, std::uint32_t val)
Add protocol message metrics.
virtual beast::Journal journal(std::string const &name)=0
virtual ManifestCache & validatorManifests()=0
std::shared_ptr< Message > getManifestsMessage()
Value removeMember(const char *key)
Remove and return the named member.
Json::Value crawlShards(bool includePublicKey, std::uint32_t relays) override
Returns information reported to the crawl shard RPC command.
std::size_t TX_REDUCE_RELAY_MIN_PEERS
void remove(std::shared_ptr< PeerFinder::Slot > const &slot)
Manages the set of connected peers.
bool TX_REDUCE_RELAY_METRICS
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...
void onPeerDeactivate(Peer::id_t id)
boost::container::flat_map< Child *, std::weak_ptr< Child > > list_
std::optional< boost::asio::io_service::work > work_
Timer(OverlayImpl &overlay)
void squelch(PublicKey const &validator, Peer::id_t const id, std::uint32_t squelchDuration) const override
Squelch handler.
Wraps a Journal::Sink to prefix its output with a string.
Used to indicate the result of a server connection handoff.
std::shared_ptr< Peer > findPeerByPublicKey(PublicKey const &pubKey) override
Returns the peer with the matching public key, or null.
Json::Value getJson() const
Return a JSON representation of the state of the validator list.
bool contains(PublicKey const &nodeId)
std::vector< std::string > IPS
metrics::TxMetrics txMetrics_
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
std::shared_ptr< Writer > makeRedirectResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address)
std::size_t TX_RELAY_PERCENTAGE
A version-independent IP address and port combination.
std::string strHex(FwdIt begin, FwdIt end)
std::weak_ptr< Timer > timer_
std::shared_ptr< boost::asio::ssl::context > context
std::shared_ptr< Writer > response
static boost::asio::ip::tcp::endpoint to_asio_endpoint(IP::Endpoint const &address)
std::optional< Manifest > deserializeManifest(Slice s, beast::Journal journal)
Constructs Manifest from serialized string.
bool TX_REDUCE_RELAY_ENABLE
PeerFinder configuration settings.
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.
std::shared_ptr< Peer > findPeerByShortID(Peer::id_t const &id) const override
Returns the peer with the matching short id, or null.
void setup(Setup const &setup, beast::Journal journal)
void reportTraffic(TrafficCount::category cat, bool isInbound, int bytes)
void addCount(category cat, bool inbound, int bytes)
Account for traffic associated with the given category.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
ManifestDisposition applyManifest(Manifest m)
Add manifest to cache.
std::shared_ptr< Writer > makeErrorResponse(std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type const &request, address_type remote_address, std::string msg)
hash_map< std::shared_ptr< PeerFinder::Slot >, std::weak_ptr< PeerImp > > m_peers
void resolve(std::vector< std::string > const &names, Handler handler)
resolve all hostnames on the list
static bool isPeerUpgrade(http_request_type const &request)
void add_active(std::shared_ptr< PeerImp > const &peer)
std::optional< ProtocolVersion > negotiateProtocolVersion(std::vector< ProtocolVersion > const &versions)
Given a list of supported protocol versions, choose the one we prefer.
boost::system::error_code error_code
void onWrite(beast::PropertyStream::Map &stream) override
Subclass override.
virtual HashRouter & getHashRouter()=0
Holds unparsed configuration information.
void for_each(UnaryFunc &&f) const
void unsquelch(PublicKey const &validator, Peer::id_t id) const override
Unsquelch handler.
@ shardInfo
shard info for signing
Section & section(std::string const &name)
Returns the section with the given name.
int limit() override
Returns the maximum number of peers we are configured to allow.
bool processCrawl(http_request_type const &req, Handoff &handoff)
Handles crawl requests.
boost::asio::ip::tcp::endpoint endpoint_type
std::uint32_t sequence() const
A monotonically increasing number used to detect new manifests.