3#include <xrpld/app/consensus/RCLCxPeerPos.h>
4#include <xrpld/app/ledger/detail/LedgerReplayMsgHandler.h>
5#include <xrpld/overlay/Squelch.h>
6#include <xrpld/overlay/detail/OverlayImpl.h>
7#include <xrpld/overlay/detail/ProtocolVersion.h>
8#include <xrpld/peerfinder/PeerfinderManager.h>
10#include <xrpl/basics/UnorderedContainers.h>
11#include <xrpl/beast/utility/WrappedSink.h>
12#include <xrpl/core/HashRouter.h>
13#include <xrpl/protocol/Protocol.h>
14#include <xrpl/protocol/STTx.h>
15#include <xrpl/protocol/STValidation.h>
16#include <xrpl/resource/Fees.h>
18#include <boost/circular_buffer.hpp>
19#include <boost/endian/conversion.hpp>
20#include <boost/thread/shared_mutex.hpp>
47 using waitable_timer = boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
61 boost::asio::strand<boost::asio::executor>
strand_;
136 XRPL_ASSERT(f >=
fee,
"xrpl::PeerImp::ChargeWithContext::update : fee increases");
235 template <
class Buffers>
239 Buffers
const& buffers,
405 getScore(
bool haveItem)
const override;
698template <
class Buffers>
702 Buffers
const& buffers,
750 boost::asio::buffer_copy(
readBuffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
753 <<
" vp reduce-relay base squelch enabled "
759template <
class FwdIt,
class>
763 protocol::TMEndpoints tm;
765 while (first != last)
767 auto& tme2(*tm.add_endpoints_v2());
768 tme2.set_endpoint(first->address.toString());
769 tme2.set_hops(first->hops);
A version-independent IP address and port combination.
A generic endpoint for log messages.
Wraps a Journal::Sink to prefix its output with a string.
Child(OverlayImpl &overlay)
std::uint64_t rollingAvgBytes_
clock_type::time_point intervalStart_
boost::circular_buffer< std::uint64_t > rollingAvg_
Metrics(Metrics const &)=delete
void addMessage(std::uint64_t bytes)
Metrics & operator=(Metrics const &)=delete
Metrics & operator=(Metrics &&)=delete
std::uint64_t averageBytes() const
Metrics(Metrics &&)=delete
std::uint64_t totalBytes() const
std::uint64_t accumBytes_
std::uint64_t totalBytes_
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
void onTimer(boost::system::error_code const &ec)
std::optional< std::chrono::milliseconds > latency_
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
std::string getVersion() const
Return the version of xrpld that the peer is running, if reported.
boost::asio::ip::tcp::endpoint endpoint_type
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
ProtocolVersion protocol_
bool txReduceRelayEnabled_
void checkTransaction(HashRouterFlags flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
std::shared_ptr< PeerFinder::Slot > const & slot()
boost::beast::tcp_stream middle_type
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
Called from onMessage(TMTransaction(s)).
http_request_type request_
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
bool txReduceRelayEnabled() const override
std::shared_ptr< PeerFinder::Slot > const slot_
boost::asio::ip::tcp::socket socket_type
compression::Compressed Compressed
boost::beast::http::fields const & headers_
Compressed compressionEnabled_
std::chrono::steady_clock clock_type
uint256 const & getClosedLedgerHash() const override
boost::system::error_code error_code
static Resource::Charge computeGetObjectByHashFee(int const requested, int const found)
Compute the per-message resource charge for a TMGetObjectByHash request based on how much work was ac...
PeerImp & operator=(PeerImp const &)=delete
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
void addLedger(uint256 const &hash, std::scoped_lock< std::mutex > const &lockedRecentLock)
boost::beast::multi_buffer readBuffer_
std::string const & fingerprint() const override
void charge(Resource::Charge const &fee, std::string const &context) override
Adjust this peer's load balance based on the type of load imposed.
bool ledgerReplayEnabled_
void sendTxQueue() override
Send aggregated transactions' hashes.
struct xrpl::PeerImp::@337373043150231020277011015352151251117171316327 metrics_
std::unique_ptr< stream_type > streamPtr_
uint256 closedLedgerHash_
reduce_relay::Squelch< UptimeClock > squelch_
PeerImp(PeerImp const &)=delete
void checkValidation(std::shared_ptr< STValidation > const &val, uint256 const &key, std::shared_ptr< protocol::TMValidation > const &packet)
void cycleStatus() override
std::shared_mutex nameMutex_
std::string domain() const
std::atomic< Tracking > tracking_
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
clock_type::duration uptime() const
boost::asio::ip::address address_type
beast::WrappedSink pSink_
PublicKey const publicKey_
void processGetObjectByHash(std::shared_ptr< protocol::TMGetObjectByHash > const &m)
Process a generic-query TMGetObjectByHash message.
bool cluster() const override
Returns true if this connection is a member of the cluster.
std::queue< std::shared_ptr< Message > > sendQueue_
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Peer::id_t id() const override
beast::Journal const pJournal_
static std::string makePrefix(std::string const &fingerprint)
beast::Journal const & pJournal() const
void onShutdown(error_code ec)
void handleHaveTransactions(std::shared_ptr< protocol::TMHaveTransactions > const &m)
Handle protocol message with hashes of transactions that have not been relayed by an upstream node do...
beast::IP::Endpoint getRemoteAddress() const override
void onMessageUnknown(std::uint16_t type)
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
bool compressionEnabled() const override
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
protocol::TMStatusChange lastStatus_
clock_type::time_point const creationTime_
LedgerReplayMsgHandler ledgerReplayMsgHandler_
void fail(std::string const &reason)
std::unique_ptr< LoadEvent > loadEvent_
void send(std::shared_ptr< Message > const &m) override
void onMessageBegin(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m, std::size_t size, std::size_t uncompressedSize, bool isCompressed)
hash_set< uint256 > txQueue_
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
bool supportsFeature(ProtocolFeature f) const override
PublicKey const & getNodePublic() const override
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
boost::asio::strand< boost::asio::executor > strand_
clock_type::time_point lastPingTime_
boost::circular_buffer< uint256 > recentLedgers_
int getScore(bool haveItem) const override
bool hasTxSet(uint256 const &hash) const override
http_response_type response_
boost::circular_buffer< uint256 > recentTxSets_
clock_type::time_point trackingTime_
beast::Journal const journal_
bool isHighLatency() const override
void cancelTimer() noexcept
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
uint256 previousLedgerHash_
Resource::Consumer usage_
std::optional< std::uint32_t > lastPingSeq_
void onWriteMessage(error_code ec, std::size_t bytesTransferred)
boost::beast::ssl_stream< middle_type > stream_type
bool crawl() const
Returns true if this connection will publicly share its IP address.
beast::IP::Endpoint const remoteAddress_
Resource::Charge currentFeeCharge() const
Read-only accessor for the accumulated peer-message charge.
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
std::string const & prefix() const
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
void onReadMessage(error_code ec, std::size_t bytesTransferred)
hash_map< PublicKey, std::size_t > publisherListSequences_
std::atomic< bool > chargeDisconnectFired_
json::Value json() override
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Represents a peer connection in the overlay.
std::uint32_t id_t
Uniquely identifies a peer.
A peer's signed, proposed position for use in RCLConsensus.
An endpoint that consumes resources.
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
Maintains squelching of relaying messages from validators.
Charge const kFeeTrivialPeer
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::uint32_t LedgerIndex
A ledger index.
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
static constexpr char kFeatureLedgerReplay[]
std::string to_string(BaseUInt< Bits, Tag > const &a)
static constexpr char kFeatureTxrr[]
std::string getFingerprint(beast::IP::Endpoint const &address, std::optional< PublicKey > const &publicKey=std::nullopt, std::optional< std::string > const &id=std::nullopt)
std::unordered_map< Key, Value, Hash, Pred, Allocator > hash_map
bool peerFeatureEnabled(Headers const &request, std::string const &feature, std::string value, bool config)
Check if a feature should be enabled for a peer.
std::pair< std::uint16_t, std::uint16_t > ProtocolVersion
Represents a particular version of the peer-to-peer protocol.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
static constexpr char kFeatureCompr[]
static constexpr char kFeatureVprr[]
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
Describes a connectable peer address along with some metadata.
void update(Resource::Charge f, std::string const &add)
Used to represent the information stored in the blobs_v2 Json array.