rippled
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
xrpl::test::tx_reduce_relay_test::PeerTest Class Reference
Inheritance diagram for xrpl::test::tx_reduce_relay_test::PeerTest:
Inheritance graph
[legend]
Collaboration diagram for xrpl::test::tx_reduce_relay_test::PeerTest:
Collaboration graph
[legend]

Public Types

enum class  Tracking { diverged , unknown , converged }
 Whether the peer's view of the ledger converges or diverges from ours. More...
 
using ptr = std::shared_ptr< Peer >
 
using id_t = std::uint32_t
 Uniquely identifies a peer.
 

Public Member Functions

 PeerTest (Application &app, std::shared_ptr< PeerFinder::Slot > const &slot, http_request_type &&request, PublicKey const &publicKey, ProtocolVersion protocol, Resource::Consumer consumer, std::unique_ptr< tx_reduce_relay_test::stream_type > &&stream_ptr, OverlayImpl &overlay)
 
 ~PeerTest ()=default
 
void run () override
 
void send (std::shared_ptr< Message > const &) override
 
void addTxQueue (uint256 const &hash) override
 Add transaction's hash to the transactions' hashes queue.
 
beast::Journal const & pJournal () const
 
std::shared_ptr< PeerFinder::Slot > const & slot ()
 
void stop () override
 
void sendTxQueue () override
 Send aggregated transactions' hashes.
 
void removeTxQueue (uint256 const &hash) override
 Remove transaction's hash from the transactions' hashes queue.
 
template<class FwdIt , class = typename std::enable_if_t< std::is_same<typename std::iterator_traits<FwdIt>::value_type, PeerFinder::Endpoint>::value>>
void sendEndpoints (FwdIt first, FwdIt last)
 Send a set of PeerFinder endpoints as a protocol message.
 
beast::IP::Endpoint getRemoteAddress () 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.
 
Peer::id_t id () const override
 
bool crawl () const
 Returns true if this connection will publicly share its IP address.
 
bool cluster () const override
 Returns true if this connection is a member of the cluster.
 
void checkTracking (std::uint32_t validationSeq)
 Check if the peer is tracking.
 
void checkTracking (std::uint32_t seq1, std::uint32_t seq2)
 
PublicKey const & getNodePublic () const override
 
std::string getVersion () const
 Return the version of rippled that the peer is running, if reported.
 
clock_type::duration uptime () const
 
Json::Value json () override
 
bool supportsFeature (ProtocolFeature f) const override
 
std::optional< std::size_tpublisherListSequence (PublicKey const &pubKey) const override
 
void setPublisherListSequence (PublicKey const &pubKey, std::size_t const seq) override
 
uint256 const & getClosedLedgerHash () const override
 
bool hasLedger (uint256 const &hash, std::uint32_t seq) const override
 
void ledgerRange (std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
 
bool hasTxSet (uint256 const &hash) const override
 
void cycleStatus () override
 
bool hasRange (std::uint32_t uMin, std::uint32_t uMax) override
 
int getScore (bool haveItem) const override
 
bool isHighLatency () const override
 
bool compressionEnabled () const override
 
bool txReduceRelayEnabled () const override
 
void onMessageUnknown (std::uint16_t type)
 
void onMessageBegin (std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m, std::size_t size, std::size_t uncompressed_size, bool isCompressed)
 
void onMessageEnd (std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
 
void onMessage (std::shared_ptr< protocol::TMManifests > const &m)
 
void onMessage (std::shared_ptr< protocol::TMPing > const &m)
 
void onMessage (std::shared_ptr< protocol::TMCluster > const &m)
 
void onMessage (std::shared_ptr< protocol::TMEndpoints > const &m)
 
void onMessage (std::shared_ptr< protocol::TMTransaction > const &m)
 
void onMessage (std::shared_ptr< protocol::TMGetLedger > const &m)
 
void onMessage (std::shared_ptr< protocol::TMLedgerData > const &m)
 
void onMessage (std::shared_ptr< protocol::TMProposeSet > const &m)
 
void onMessage (std::shared_ptr< protocol::TMStatusChange > const &m)
 
void onMessage (std::shared_ptr< protocol::TMHaveTransactionSet > const &m)
 
void onMessage (std::shared_ptr< protocol::TMValidatorList > const &m)
 
void onMessage (std::shared_ptr< protocol::TMValidatorListCollection > const &m)
 
void onMessage (std::shared_ptr< protocol::TMValidation > const &m)
 
void onMessage (std::shared_ptr< protocol::TMGetObjectByHash > const &m)
 
void onMessage (std::shared_ptr< protocol::TMHaveTransactions > const &m)
 
void onMessage (std::shared_ptr< protocol::TMTransactions > const &m)
 
void onMessage (std::shared_ptr< protocol::TMSquelch > const &m)
 
void onMessage (std::shared_ptr< protocol::TMProofPathRequest > const &m)
 
void onMessage (std::shared_ptr< protocol::TMProofPathResponse > const &m)
 
void onMessage (std::shared_ptr< protocol::TMReplayDeltaRequest > const &m)
 
void onMessage (std::shared_ptr< protocol::TMReplayDeltaResponse > const &m)
 
shared_from_this (T... args)
 
weak_from_this (T... args)
 

Static Public Member Functions

static void init ()
 

Static Public Attributes

static std::size_t sid_ = 0
 
static std::uint16_t queueTx_ = 0
 
static std::uint16_t sendTx_ = 0
 

Private Types

using clock_type = std::chrono::steady_clock
 
using error_code = boost::system::error_code
 
using socket_type = boost::asio::ip::tcp::socket
 
using middle_type = boost::beast::tcp_stream
 
using stream_type = boost::beast::ssl_stream< middle_type >
 
using address_type = boost::asio::ip::address
 
using endpoint_type = boost::asio::ip::tcp::endpoint
 
using waitable_timer = boost::asio::basic_waitable_timer< std::chrono::steady_clock >
 
using Compressed = compression::Compressed
 

Private Member Functions

void fail (std::string const &name, error_code ec)
 Handles a failure associated with a specific error code.
 
void fail (std::string const &reason)
 Handles a failure described by a reason string.
 
void shutdown ()
 Initiates the peer disconnection sequence.
 
void tryAsyncShutdown ()
 Attempts to perform a graceful SSL shutdown if conditions are met.
 
void onShutdown (error_code ec)
 Handles the completion of the asynchronous SSL shutdown.
 
void close ()
 Forcibly closes the underlying socket connection.
 
void setTimer (std::chrono::seconds interval)
 Sets and starts the peer timer.
 
void onTimer (error_code const &ec)
 Handles the expiration of the peer activity timer.
 
void cancelTimer () noexcept
 Cancels any pending wait on the peer activity timer.
 
void doAccept ()
 
std::string name () const
 
std::string domain () const
 
void doProtocolStart ()
 
void onReadMessage (error_code ec, std::size_t bytes_transferred)
 
void onWriteMessage (error_code ec, std::size_t bytes_transferred)
 
void handleTransaction (std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
 Called from onMessage(TMTransaction(s)).
 
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 down to its peers - request transactions, which have not been relayed to this peer.
 
std::string const & fingerprint () const override
 
std::string const & prefix () const
 
void addLedger (uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
 
void doFetchPack (std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
 
void onValidatorListMessage (std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
 
void doTransactions (std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
 Process peer's request to send missing transactions.
 
void checkTransaction (HashRouterFlags flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
 
void checkPropose (bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
 
void checkValidation (std::shared_ptr< STValidation > const &val, uint256 const &key, std::shared_ptr< protocol::TMValidation > const &packet)
 
void sendLedgerBase (std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
 
std::shared_ptr< Ledger const > getLedger (std::shared_ptr< protocol::TMGetLedger > const &m)
 
std::shared_ptr< SHAMap const > getTxSet (std::shared_ptr< protocol::TMGetLedger > const &m) const
 
void processLedgerRequest (std::shared_ptr< protocol::TMGetLedger > const &m)
 

Static Private Member Functions

static std::string makePrefix (std::string const &fingerprint)
 

Private Attributes

Applicationapp_
 
id_t const id_
 
std::string fingerprint_
 
std::string prefix_
 
beast::WrappedSink sink_
 
beast::WrappedSink p_sink_
 
beast::Journal const journal_
 
beast::Journal const p_journal_
 
std::unique_ptr< stream_typestream_ptr_
 
socket_typesocket_
 
stream_typestream_
 
boost::asio::strand< boost::asio::executor > strand_
 
waitable_timer timer_
 
beast::IP::Endpoint const remote_address_
 
OverlayImploverlay_
 
bool const inbound_
 
ProtocolVersion protocol_
 
std::atomic< Trackingtracking_
 
clock_type::time_point trackingTime_
 
PublicKey const publicKey_
 
std::string name_
 
std::shared_mutex nameMutex_
 
LedgerIndex minLedger_ = 0
 
LedgerIndex maxLedger_ = 0
 
uint256 closedLedgerHash_
 
uint256 previousLedgerHash_
 
boost::circular_buffer< uint256recentLedgers_ {128}
 
boost::circular_buffer< uint256recentTxSets_ {128}
 
std::optional< std::chrono::millisecondslatency_
 
std::optional< std::uint32_tlastPingSeq_
 
clock_type::time_point lastPingTime_
 
clock_type::time_point const creationTime_
 
reduce_relay::Squelch< UptimeClocksquelch_
 
std::mutex recentLock_
 
protocol::TMStatusChange last_status_
 
Resource::Consumer usage_
 
ChargeWithContext fee_
 
std::shared_ptr< PeerFinder::Slot > const slot_
 
boost::beast::multi_buffer read_buffer_
 
http_request_type request_
 
http_response_type response_
 
boost::beast::http::fields const & headers_
 
std::queue< std::shared_ptr< Message > > send_queue_
 
bool shutdown_ = false
 
bool shutdownStarted_ = false
 
bool readPending_ = false
 
bool writePending_ = false
 
int large_sendq_ = 0
 
std::unique_ptr< LoadEventload_event_
 
hash_map< PublicKey, std::size_tpublisherListSequences_
 
Compressed compressionEnabled_ = Compressed::Off
 
hash_set< uint256txQueue_
 
bool txReduceRelayEnabled_ = false
 
bool ledgerReplayEnabled_ = false
 
LedgerReplayMsgHandler ledgerReplayMsgHandler_
 
struct { 
 
   Metrics   sent 
 
   Metrics   recv 
 
metrics_ 
 

Detailed Description

Definition at line 74 of file tx_reduce_relay_test.cpp.

Member Typedef Documentation

◆ clock_type

Definition at line 102 of file PeerImp.h.

◆ error_code

using xrpl::PeerImp::error_code = boost::system::error_code
privateinherited

Definition at line 103 of file PeerImp.h.

◆ socket_type

using xrpl::PeerImp::socket_type = boost::asio::ip::tcp::socket
privateinherited

Definition at line 104 of file PeerImp.h.

◆ middle_type

using xrpl::PeerImp::middle_type = boost::beast::tcp_stream
privateinherited

Definition at line 105 of file PeerImp.h.

◆ stream_type

using xrpl::PeerImp::stream_type = boost::beast::ssl_stream<middle_type>
privateinherited

Definition at line 106 of file PeerImp.h.

◆ address_type

using xrpl::PeerImp::address_type = boost::asio::ip::address
privateinherited

Definition at line 107 of file PeerImp.h.

◆ endpoint_type

using xrpl::PeerImp::endpoint_type = boost::asio::ip::tcp::endpoint
privateinherited

Definition at line 108 of file PeerImp.h.

◆ waitable_timer

using xrpl::PeerImp::waitable_timer = boost::asio::basic_waitable_timer<std::chrono::steady_clock>
privateinherited

Definition at line 109 of file PeerImp.h.

◆ Compressed

Definition at line 110 of file PeerImp.h.

◆ ptr

using xrpl::Peer::ptr = std::shared_ptr<Peer>
inherited

Definition at line 26 of file xrpld/overlay/Peer.h.

◆ id_t

using xrpl::Peer::id_t = std::uint32_t
inherited

Uniquely identifies a peer.

This can be stored in tables to find the peer later. Callers can discover if the peer is no longer connected and make adjustments as needed.

Definition at line 33 of file xrpld/overlay/Peer.h.

Member Enumeration Documentation

◆ Tracking

enum class xrpl::PeerImp::Tracking
stronginherited

Whether the peer's view of the ledger converges or diverges from ours.

Enumerator
diverged 
unknown 
converged 

Definition at line 99 of file PeerImp.h.

Constructor & Destructor Documentation

◆ PeerTest()

xrpl::test::tx_reduce_relay_test::PeerTest::PeerTest ( Application app,
std::shared_ptr< PeerFinder::Slot > const &  slot,
http_request_type &&  request,
PublicKey const &  publicKey,
ProtocolVersion  protocol,
Resource::Consumer  consumer,
std::unique_ptr< tx_reduce_relay_test::stream_type > &&  stream_ptr,
OverlayImpl overlay 
)

Definition at line 77 of file tx_reduce_relay_test.cpp.

◆ ~PeerTest()

xrpl::test::tx_reduce_relay_test::PeerTest::~PeerTest ( )
default

Member Function Documentation

◆ run()

void xrpl::test::tx_reduce_relay_test::PeerTest::run ( )
overridevirtual

Reimplemented from xrpl::PeerImp.

Definition at line 102 of file tx_reduce_relay_test.cpp.

◆ send()

void xrpl::test::tx_reduce_relay_test::PeerTest::send ( std::shared_ptr< Message > const &  )
overridevirtual

Reimplemented from xrpl::PeerImp.

Definition at line 106 of file tx_reduce_relay_test.cpp.

◆ addTxQueue()

void xrpl::test::tx_reduce_relay_test::PeerTest::addTxQueue ( uint256 const &  hash)
overridevirtual

Add transaction's hash to the transactions' hashes queue.

Parameters
hashtransaction's hash

Reimplemented from xrpl::PeerImp.

Definition at line 111 of file tx_reduce_relay_test.cpp.

◆ init()

static void xrpl::test::tx_reduce_relay_test::PeerTest::init ( )
static

Definition at line 116 of file tx_reduce_relay_test.cpp.

◆ pJournal()

beast::Journal const & xrpl::PeerImp::pJournal ( ) const
inherited

Definition at line 320 of file PeerImp.h.

◆ slot()

std::shared_ptr< PeerFinder::Slot > const & xrpl::PeerImp::slot ( )
inherited

Definition at line 326 of file PeerImp.h.

◆ stop()

void xrpl::PeerImp::stop ( )
overridevirtualinherited

Implements xrpl::OverlayImpl::Child.

Definition at line 184 of file PeerImp.cpp.

◆ sendTxQueue()

void xrpl::PeerImp::sendTxQueue ( )
overridevirtualinherited

Send aggregated transactions' hashes.

Implements xrpl::Peer.

Definition at line 263 of file PeerImp.cpp.

◆ removeTxQueue()

void xrpl::PeerImp::removeTxQueue ( uint256 const &  hash)
overridevirtualinherited

Remove transaction's hash from the transactions' hashes queue.

Parameters
hashtransaction's hash

Implements xrpl::Peer.

Definition at line 296 of file PeerImp.cpp.

◆ sendEndpoints()

template<class FwdIt , class >
void xrpl::PeerImp::sendEndpoints ( FwdIt  first,
FwdIt  last 
)
inherited

Send a set of PeerFinder endpoints as a protocol message.

Definition at line 849 of file PeerImp.h.

◆ getRemoteAddress()

beast::IP::Endpoint xrpl::PeerImp::getRemoteAddress ( ) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 371 of file PeerImp.h.

◆ charge()

void xrpl::PeerImp::charge ( Resource::Charge const &  fee,
std::string const &  context 
)
overridevirtualinherited

Adjust this peer's load balance based on the type of load imposed.

Implements xrpl::Peer.

Definition at line 306 of file PeerImp.cpp.

◆ id()

Peer::id_t xrpl::PeerImp::id ( ) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 384 of file PeerImp.h.

◆ crawl()

bool xrpl::PeerImp::crawl ( ) const
inherited

Returns true if this connection will publicly share its IP address.

Definition at line 320 of file PeerImp.cpp.

◆ cluster()

bool xrpl::PeerImp::cluster ( ) const
overridevirtualinherited

Returns true if this connection is a member of the cluster.

Implements xrpl::Peer.

Definition at line 329 of file PeerImp.cpp.

◆ checkTracking() [1/2]

void xrpl::PeerImp::checkTracking ( std::uint32_t  validationSeq)
inherited

Check if the peer is tracking.

Parameters
validationSeqThe ledger sequence of a recently-validated ledger

Definition at line 1872 of file PeerImp.cpp.

◆ checkTracking() [2/2]

void xrpl::PeerImp::checkTracking ( std::uint32_t  seq1,
std::uint32_t  seq2 
)
inherited

Definition at line 1891 of file PeerImp.cpp.

◆ getNodePublic()

PublicKey const & xrpl::PeerImp::getNodePublic ( ) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 406 of file PeerImp.h.

◆ getVersion()

std::string xrpl::PeerImp::getVersion ( ) const
inherited

Return the version of rippled that the peer is running, if reported.

Definition at line 335 of file PeerImp.cpp.

◆ uptime()

clock_type::duration xrpl::PeerImp::uptime ( ) const
inherited

Definition at line 417 of file PeerImp.h.

◆ json()

Json::Value xrpl::PeerImp::json ( )
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 343 of file PeerImp.cpp.

◆ supportsFeature()

bool xrpl::PeerImp::supportsFeature ( ProtocolFeature  f) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 454 of file PeerImp.cpp.

◆ publisherListSequence()

std::optional< std::size_t > xrpl::PeerImp::publisherListSequence ( PublicKey const &  pubKey) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 429 of file PeerImp.h.

◆ setPublisherListSequence()

void xrpl::PeerImp::setPublisherListSequence ( PublicKey const &  pubKey,
std::size_t const  seq 
)
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 440 of file PeerImp.h.

◆ getClosedLedgerHash()

uint256 const & xrpl::PeerImp::getClosedLedgerHash ( ) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 452 of file PeerImp.h.

◆ hasLedger()

bool xrpl::PeerImp::hasLedger ( uint256 const &  hash,
std::uint32_t  seq 
) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 471 of file PeerImp.cpp.

◆ ledgerRange()

void xrpl::PeerImp::ledgerRange ( std::uint32_t minSeq,
std::uint32_t maxSeq 
) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 484 of file PeerImp.cpp.

◆ hasTxSet()

bool xrpl::PeerImp::hasTxSet ( uint256 const &  hash) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 493 of file PeerImp.cpp.

◆ cycleStatus()

void xrpl::PeerImp::cycleStatus ( )
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 500 of file PeerImp.cpp.

◆ hasRange()

bool xrpl::PeerImp::hasRange ( std::uint32_t  uMin,
std::uint32_t  uMax 
)
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 510 of file PeerImp.cpp.

◆ getScore()

int xrpl::PeerImp::getScore ( bool  haveItem) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 3210 of file PeerImp.cpp.

◆ isHighLatency()

bool xrpl::PeerImp::isHighLatency ( ) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 3248 of file PeerImp.cpp.

◆ compressionEnabled()

bool xrpl::PeerImp::compressionEnabled ( ) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 480 of file PeerImp.h.

◆ txReduceRelayEnabled()

bool xrpl::PeerImp::txReduceRelayEnabled ( ) const
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 486 of file PeerImp.h.

◆ fail() [1/2]

void xrpl::PeerImp::fail ( std::string const &  name,
error_code  ec 
)
privateinherited

Handles a failure associated with a specific error code.

This function is called when an operation fails with an error code. It logs the warning message and gracefully shutdowns the connection.

The function will do nothing if the connection is already closed or if a shutdown is already in progress.

Parameters
nameThe name of the operation that failed (e.g., "read", "write").
ecThe error code associated with the failure.
Note
This function must be called from within the object's strand.

Definition at line 519 of file PeerImp.cpp.

◆ fail() [2/2]

void xrpl::PeerImp::fail ( std::string const &  reason)
privateinherited

Handles a failure described by a reason string.

This overload is used for logical errors or protocol violations not associated with a specific error code. It logs a warning with the given reason, then initiates a graceful shutdown.

The function will do nothing if the connection is already closed or if a shutdown is already in progress.

Parameters
reasonA descriptive string explaining the reason for the failure.
Note
This function must be called from within the object's strand.

Definition at line 532 of file PeerImp.cpp.

◆ shutdown()

void xrpl::PeerImp::shutdown ( )
privateinherited

Initiates the peer disconnection sequence.

This is the primary entry point to start closing a peer connection. It marks the peer for shutdown and cancels any outstanding asynchronous operations. This cancellation allows the graceful shutdown to proceed once the handlers for the cancelled operations have completed.

Note
This method must be called on the peer's strand.

Definition at line 572 of file PeerImp.cpp.

◆ tryAsyncShutdown()

void xrpl::PeerImp::tryAsyncShutdown ( )
privateinherited

Attempts to perform a graceful SSL shutdown if conditions are met.

This helper function checks if the peer is in a state where a graceful SSL shutdown can be performed (i.e., shutdown has been requested and no I/O operations are currently in progress).

Note
This method must be called on the peer's strand.

Definition at line 552 of file PeerImp.cpp.

◆ onShutdown()

void xrpl::PeerImp::onShutdown ( error_code  ec)
privateinherited

Handles the completion of the asynchronous SSL shutdown.

This function is the callback for the async_shutdown operation started in shutdown(). Its first action is to cancel the timer. It then inspects the error code to determine the outcome.

Regardless of the result, this function proceeds to call close() to ensure the underlying socket is fully closed.

Parameters
ecThe error code resulting from the async_shutdown operation.

Definition at line 587 of file PeerImp.cpp.

◆ close()

void xrpl::PeerImp::close ( )
privateinherited

Forcibly closes the underlying socket connection.

This function provides the final, non-graceful shutdown of the peer connection. It ensures any pending timers are cancelled and then immediately closes the TCP socket, bypassing the SSL shutdown handshake.

After closing, it notifies the overlay manager of the disconnection.

Note
This function must be called from within the object's strand.

Definition at line 611 of file PeerImp.cpp.

◆ setTimer()

void xrpl::PeerImp::setTimer ( std::chrono::seconds  interval)
privateinherited

Sets and starts the peer timer.

This function starts timer, which is used to detect inactivity and prevent stalled connections. It sets the timer to expire after the predefined peerTimerInterval.

Note
This function will terminate the connection in case of any errors.

Definition at line 635 of file PeerImp.cpp.

◆ onTimer()

void xrpl::PeerImp::onTimer ( error_code const &  ec)
privateinherited

Handles the expiration of the peer activity timer.

This callback is invoked when the timer set by setTimer expires. It watches the peer connection, checking for various timeout and health conditions.

Parameters
ecThe error code associated with the timer's expiration. operation_aborted is expected if the timer was cancelled.

Definition at line 661 of file PeerImp.cpp.

◆ cancelTimer()

void xrpl::PeerImp::cancelTimer ( )
privatenoexceptinherited

Cancels any pending wait on the peer activity timer.

This function is called to stop the timer. It gracefully manages any errors that might occur during the cancellation process.

Definition at line 724 of file PeerImp.cpp.

◆ makePrefix()

std::string xrpl::PeerImp::makePrefix ( std::string const &  fingerprint)
staticprivateinherited

Definition at line 653 of file PeerImp.cpp.

◆ doAccept()

void xrpl::PeerImp::doAccept ( )
privateinherited

Definition at line 738 of file PeerImp.cpp.

◆ name()

std::string xrpl::PeerImp::name ( ) const
privateinherited

Definition at line 804 of file PeerImp.cpp.

◆ domain()

std::string xrpl::PeerImp::domain ( ) const
privateinherited

Definition at line 811 of file PeerImp.cpp.

◆ doProtocolStart()

void xrpl::PeerImp::doProtocolStart ( )
privateinherited

Definition at line 821 of file PeerImp.cpp.

◆ onReadMessage()

void xrpl::PeerImp::onReadMessage ( error_code  ec,
std::size_t  bytes_transferred 
)
privateinherited

Definition at line 854 of file PeerImp.cpp.

◆ onWriteMessage()

void xrpl::PeerImp::onWriteMessage ( error_code  ec,
std::size_t  bytes_transferred 
)
privateinherited

Definition at line 933 of file PeerImp.cpp.

◆ handleTransaction()

void xrpl::PeerImp::handleTransaction ( std::shared_ptr< protocol::TMTransaction > const &  m,
bool  eraseTxQueue,
bool  batch 
)
privateinherited

Called from onMessage(TMTransaction(s)).

Parameters
mTransaction protocol message
eraseTxQueueis true when called from onMessage(TMTransaction) and is false when called from onMessage(TMTransactions). If true then the transaction hash is erased from txQueue_. Don't need to erase from the queue when called from onMessage(TMTransactions) because this message is a response to the missing transactions request and the queue would not have any of these transactions.
batchis false when called from onMessage(TMTransaction) and is true when called from onMessage(TMTransactions). If true, then the transaction is part of a batch, and should not be charged an extra fee.

Definition at line 1218 of file PeerImp.cpp.

◆ handleHaveTransactions()

void xrpl::PeerImp::handleHaveTransactions ( std::shared_ptr< protocol::TMHaveTransactions > const &  m)
privateinherited

Handle protocol message with hashes of transactions that have not been relayed by an upstream node down to its peers - request transactions, which have not been relayed to this peer.

Parameters
mprotocol message with transactions' hashes

Definition at line 2443 of file PeerImp.cpp.

◆ fingerprint()

std::string const & xrpl::PeerImp::fingerprint ( ) const
overrideprivatevirtualinherited

Implements xrpl::Peer.

Definition at line 664 of file PeerImp.h.

◆ prefix()

std::string const & xrpl::PeerImp::prefix ( ) const
privateinherited

Definition at line 670 of file PeerImp.h.

◆ onMessageUnknown()

void xrpl::PeerImp::onMessageUnknown ( std::uint16_t  type)
inherited

Definition at line 985 of file PeerImp.cpp.

◆ onMessageBegin()

void xrpl::PeerImp::onMessageBegin ( std::uint16_t  type,
std::shared_ptr<::google::protobuf::Message > const &  m,
std::size_t  size,
std::size_t  uncompressed_size,
bool  isCompressed 
)
inherited

Definition at line 991 of file PeerImp.cpp.

◆ onMessageEnd()

void xrpl::PeerImp::onMessageEnd ( std::uint16_t  type,
std::shared_ptr<::google::protobuf::Message > const &  m 
)
inherited

Definition at line 1028 of file PeerImp.cpp.

◆ onMessage() [1/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMManifests > const &  m)
inherited

Definition at line 1035 of file PeerImp.cpp.

◆ onMessage() [2/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMPing > const &  m)
inherited

Definition at line 1053 of file PeerImp.cpp.

◆ onMessage() [3/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMCluster > const &  m)
inherited

Definition at line 1089 of file PeerImp.cpp.

◆ onMessage() [4/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMEndpoints > const &  m)
inherited

Definition at line 1158 of file PeerImp.cpp.

◆ onMessage() [5/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMTransaction > const &  m)
inherited

Definition at line 1212 of file PeerImp.cpp.

◆ onMessage() [6/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMGetLedger > const &  m)
inherited

Definition at line 1338 of file PeerImp.cpp.

◆ onMessage() [7/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMLedgerData > const &  m)
inherited

Definition at line 1515 of file PeerImp.cpp.

◆ onMessage() [8/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMProposeSet > const &  m)
inherited

Definition at line 1599 of file PeerImp.cpp.

◆ onMessage() [9/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMStatusChange > const &  m)
inherited

Definition at line 1701 of file PeerImp.cpp.

◆ onMessage() [10/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMHaveTransactionSet > const &  m)
inherited

Definition at line 1912 of file PeerImp.cpp.

◆ onMessage() [11/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMValidatorList > const &  m)
inherited

Definition at line 2126 of file PeerImp.cpp.

◆ onMessage() [12/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMValidatorListCollection > const &  m)
inherited

Definition at line 2149 of file PeerImp.cpp.

◆ onMessage() [13/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMValidation > const &  m)
inherited

Definition at line 2180 of file PeerImp.cpp.

◆ onMessage() [14/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMGetObjectByHash > const &  m)
inherited

Definition at line 2275 of file PeerImp.cpp.

◆ onMessage() [15/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMHaveTransactions > const &  m)
inherited

Definition at line 2426 of file PeerImp.cpp.

◆ onMessage() [16/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMTransactions > const &  m)
inherited

Definition at line 2489 of file PeerImp.cpp.

◆ onMessage() [17/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMSquelch > const &  m)
inherited

Definition at line 2510 of file PeerImp.cpp.

◆ onMessage() [18/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMProofPathRequest > const &  m)
inherited

Definition at line 1423 of file PeerImp.cpp.

◆ onMessage() [19/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMProofPathResponse > const &  m)
inherited

Definition at line 1454 of file PeerImp.cpp.

◆ onMessage() [20/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMReplayDeltaRequest > const &  m)
inherited

Definition at line 1469 of file PeerImp.cpp.

◆ onMessage() [21/21]

void xrpl::PeerImp::onMessage ( std::shared_ptr< protocol::TMReplayDeltaResponse > const &  m)
inherited

Definition at line 1500 of file PeerImp.cpp.

◆ addLedger()

void xrpl::PeerImp::addLedger ( uint256 const &  hash,
std::lock_guard< std::mutex > const &  lockedRecentLock 
)
privateinherited

Definition at line 2549 of file PeerImp.cpp.

◆ doFetchPack()

void xrpl::PeerImp::doFetchPack ( std::shared_ptr< protocol::TMGetObjectByHash > const &  packet)
privateinherited

Definition at line 2562 of file PeerImp.cpp.

◆ onValidatorListMessage()

void xrpl::PeerImp::onValidatorListMessage ( std::string const &  messageType,
std::string const &  manifest,
std::uint32_t  version,
std::vector< ValidatorBlobInfo > const &  blobs 
)
privateinherited

Definition at line 1937 of file PeerImp.cpp.

◆ doTransactions()

void xrpl::PeerImp::doTransactions ( std::shared_ptr< protocol::TMGetObjectByHash > const &  packet)
privateinherited

Process peer's request to send missing transactions.

The request is sent in response to TMHaveTransactions.

Parameters
packetprotocol message containing missing transactions' hashes.

Definition at line 2594 of file PeerImp.cpp.

◆ checkTransaction()

void xrpl::PeerImp::checkTransaction ( HashRouterFlags  flags,
bool  checkSignature,
std::shared_ptr< STTx const > const &  stx,
bool  batch 
)
privateinherited

Definition at line 2643 of file PeerImp.cpp.

◆ checkPropose()

void xrpl::PeerImp::checkPropose ( bool  isTrusted,
std::shared_ptr< protocol::TMProposeSet > const &  packet,
RCLCxPeerPos  peerPos 
)
privateinherited

Definition at line 2775 of file PeerImp.cpp.

◆ checkValidation()

void xrpl::PeerImp::checkValidation ( std::shared_ptr< STValidation > const &  val,
uint256 const &  key,
std::shared_ptr< protocol::TMValidation > const &  packet 
)
privateinherited

Definition at line 2810 of file PeerImp.cpp.

◆ sendLedgerBase()

void xrpl::PeerImp::sendLedgerBase ( std::shared_ptr< Ledger const > const &  ledger,
protocol::TMLedgerData &  ledgerData 
)
privateinherited

Definition at line 2897 of file PeerImp.cpp.

◆ getLedger()

std::shared_ptr< Ledger const > xrpl::PeerImp::getLedger ( std::shared_ptr< protocol::TMGetLedger > const &  m)
privateinherited

Definition at line 2932 of file PeerImp.cpp.

◆ getTxSet()

std::shared_ptr< SHAMap const > xrpl::PeerImp::getTxSet ( std::shared_ptr< protocol::TMGetLedger > const &  m) const
privateinherited

Definition at line 3015 of file PeerImp.cpp.

◆ processLedgerRequest()

void xrpl::PeerImp::processLedgerRequest ( std::shared_ptr< protocol::TMGetLedger > const &  m)
privateinherited

Definition at line 3047 of file PeerImp.cpp.

Member Data Documentation

◆ sid_

std::size_t xrpl::test::tx_reduce_relay_test::PeerTest::sid_ = 0
static

Definition at line 122 of file tx_reduce_relay_test.cpp.

◆ queueTx_

std::uint16_t xrpl::test::tx_reduce_relay_test::PeerTest::queueTx_ = 0
static

Definition at line 123 of file tx_reduce_relay_test.cpp.

◆ sendTx_

std::uint16_t xrpl::test::tx_reduce_relay_test::PeerTest::sendTx_ = 0
static

Definition at line 124 of file tx_reduce_relay_test.cpp.

◆ app_

Application& xrpl::PeerImp::app_
privateinherited

Definition at line 112 of file PeerImp.h.

◆ id_

id_t const xrpl::PeerImp::id_
privateinherited

Definition at line 113 of file PeerImp.h.

◆ fingerprint_

std::string xrpl::PeerImp::fingerprint_
privateinherited

Definition at line 114 of file PeerImp.h.

◆ prefix_

std::string xrpl::PeerImp::prefix_
privateinherited

Definition at line 115 of file PeerImp.h.

◆ sink_

beast::WrappedSink xrpl::PeerImp::sink_
privateinherited

Definition at line 116 of file PeerImp.h.

◆ p_sink_

beast::WrappedSink xrpl::PeerImp::p_sink_
privateinherited

Definition at line 117 of file PeerImp.h.

◆ journal_

beast::Journal const xrpl::PeerImp::journal_
privateinherited

Definition at line 118 of file PeerImp.h.

◆ p_journal_

beast::Journal const xrpl::PeerImp::p_journal_
privateinherited

Definition at line 119 of file PeerImp.h.

◆ stream_ptr_

std::unique_ptr<stream_type> xrpl::PeerImp::stream_ptr_
privateinherited

Definition at line 120 of file PeerImp.h.

◆ socket_

socket_type& xrpl::PeerImp::socket_
privateinherited

Definition at line 121 of file PeerImp.h.

◆ stream_

stream_type& xrpl::PeerImp::stream_
privateinherited

Definition at line 122 of file PeerImp.h.

◆ strand_

boost::asio::strand<boost::asio::executor> xrpl::PeerImp::strand_
privateinherited

Definition at line 123 of file PeerImp.h.

◆ timer_

waitable_timer xrpl::PeerImp::timer_
privateinherited

Definition at line 126 of file PeerImp.h.

◆ remote_address_

beast::IP::Endpoint const xrpl::PeerImp::remote_address_
privateinherited

Definition at line 130 of file PeerImp.h.

◆ overlay_

OverlayImpl& xrpl::PeerImp::overlay_
privateinherited

Definition at line 134 of file PeerImp.h.

◆ inbound_

bool const xrpl::PeerImp::inbound_
privateinherited

Definition at line 135 of file PeerImp.h.

◆ protocol_

ProtocolVersion xrpl::PeerImp::protocol_
privateinherited

Definition at line 138 of file PeerImp.h.

◆ tracking_

std::atomic<Tracking> xrpl::PeerImp::tracking_
privateinherited

Definition at line 140 of file PeerImp.h.

◆ trackingTime_

clock_type::time_point xrpl::PeerImp::trackingTime_
privateinherited

Definition at line 141 of file PeerImp.h.

◆ publicKey_

PublicKey const xrpl::PeerImp::publicKey_
privateinherited

Definition at line 143 of file PeerImp.h.

◆ name_

std::string xrpl::PeerImp::name_
privateinherited

Definition at line 144 of file PeerImp.h.

◆ nameMutex_

std::shared_mutex xrpl::PeerImp::nameMutex_
mutableprivateinherited

Definition at line 145 of file PeerImp.h.

◆ minLedger_

LedgerIndex xrpl::PeerImp::minLedger_ = 0
privateinherited

Definition at line 149 of file PeerImp.h.

◆ maxLedger_

LedgerIndex xrpl::PeerImp::maxLedger_ = 0
privateinherited

Definition at line 150 of file PeerImp.h.

◆ closedLedgerHash_

uint256 xrpl::PeerImp::closedLedgerHash_
privateinherited

Definition at line 151 of file PeerImp.h.

◆ previousLedgerHash_

uint256 xrpl::PeerImp::previousLedgerHash_
privateinherited

Definition at line 152 of file PeerImp.h.

◆ recentLedgers_

boost::circular_buffer<uint256> xrpl::PeerImp::recentLedgers_ {128}
privateinherited

Definition at line 154 of file PeerImp.h.

◆ recentTxSets_

boost::circular_buffer<uint256> xrpl::PeerImp::recentTxSets_ {128}
privateinherited

Definition at line 155 of file PeerImp.h.

◆ latency_

std::optional<std::chrono::milliseconds> xrpl::PeerImp::latency_
privateinherited

Definition at line 157 of file PeerImp.h.

◆ lastPingSeq_

std::optional<std::uint32_t> xrpl::PeerImp::lastPingSeq_
privateinherited

Definition at line 158 of file PeerImp.h.

◆ lastPingTime_

clock_type::time_point xrpl::PeerImp::lastPingTime_
privateinherited

Definition at line 159 of file PeerImp.h.

◆ creationTime_

clock_type::time_point const xrpl::PeerImp::creationTime_
privateinherited

Definition at line 160 of file PeerImp.h.

◆ squelch_

reduce_relay::Squelch<UptimeClock> xrpl::PeerImp::squelch_
privateinherited

Definition at line 162 of file PeerImp.h.

◆ recentLock_

std::mutex xrpl::PeerImp::recentLock_
mutableprivateinherited

Definition at line 209 of file PeerImp.h.

◆ last_status_

protocol::TMStatusChange xrpl::PeerImp::last_status_
privateinherited

Definition at line 210 of file PeerImp.h.

◆ usage_

Resource::Consumer xrpl::PeerImp::usage_
privateinherited

Definition at line 211 of file PeerImp.h.

◆ fee_

ChargeWithContext xrpl::PeerImp::fee_
privateinherited

Definition at line 212 of file PeerImp.h.

◆ slot_

std::shared_ptr<PeerFinder::Slot> const xrpl::PeerImp::slot_
privateinherited

Definition at line 213 of file PeerImp.h.

◆ read_buffer_

boost::beast::multi_buffer xrpl::PeerImp::read_buffer_
privateinherited

Definition at line 214 of file PeerImp.h.

◆ request_

http_request_type xrpl::PeerImp::request_
privateinherited

Definition at line 215 of file PeerImp.h.

◆ response_

http_response_type xrpl::PeerImp::response_
privateinherited

Definition at line 216 of file PeerImp.h.

◆ headers_

boost::beast::http::fields const& xrpl::PeerImp::headers_
privateinherited

Definition at line 217 of file PeerImp.h.

◆ send_queue_

std::queue<std::shared_ptr<Message> > xrpl::PeerImp::send_queue_
privateinherited

Definition at line 218 of file PeerImp.h.

◆ shutdown_

bool xrpl::PeerImp::shutdown_ = false
privateinherited

Definition at line 221 of file PeerImp.h.

◆ shutdownStarted_

bool xrpl::PeerImp::shutdownStarted_ = false
privateinherited

Definition at line 224 of file PeerImp.h.

◆ readPending_

bool xrpl::PeerImp::readPending_ = false
privateinherited

Definition at line 227 of file PeerImp.h.

◆ writePending_

bool xrpl::PeerImp::writePending_ = false
privateinherited

Definition at line 230 of file PeerImp.h.

◆ large_sendq_

int xrpl::PeerImp::large_sendq_ = 0
privateinherited

Definition at line 232 of file PeerImp.h.

◆ load_event_

std::unique_ptr<LoadEvent> xrpl::PeerImp::load_event_
privateinherited

Definition at line 233 of file PeerImp.h.

◆ publisherListSequences_

hash_map<PublicKey, std::size_t> xrpl::PeerImp::publisherListSequences_
privateinherited

Definition at line 236 of file PeerImp.h.

◆ compressionEnabled_

Compressed xrpl::PeerImp::compressionEnabled_ = Compressed::Off
privateinherited

Definition at line 238 of file PeerImp.h.

◆ txQueue_

hash_set<uint256> xrpl::PeerImp::txQueue_
privateinherited

Definition at line 243 of file PeerImp.h.

◆ txReduceRelayEnabled_

bool xrpl::PeerImp::txReduceRelayEnabled_ = false
privateinherited

Definition at line 245 of file PeerImp.h.

◆ ledgerReplayEnabled_

bool xrpl::PeerImp::ledgerReplayEnabled_ = false
privateinherited

Definition at line 247 of file PeerImp.h.

◆ ledgerReplayMsgHandler_

LedgerReplayMsgHandler xrpl::PeerImp::ledgerReplayMsgHandler_
privateinherited

Definition at line 248 of file PeerImp.h.

◆ sent

Metrics xrpl::PeerImp::sent
inherited

Definition at line 281 of file PeerImp.h.

◆ recv

Metrics xrpl::PeerImp::recv
inherited

Definition at line 282 of file PeerImp.h.

◆ [struct]

struct { ... } xrpl::PeerImp::metrics_