xrpld
Loading...
Searching...
No Matches
xrpl::test::TMGetObjectByHash_test::PeerTest Class Reference

Test peer that captures sent messages for verification. More...

Inheritance diagram for xrpl::test::TMGetObjectByHash_test::PeerTest:
Collaboration diagram for xrpl::test::TMGetObjectByHash_test::PeerTest:

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< TMGetObjectByHash_test::stream_type > &&streamPtr, OverlayImpl &overlay)
 ~PeerTest () override=default
void run () override
void send (std::shared_ptr< Message > const &m) override
std::shared_ptr< MessagegetLastSentMessage () const
void runProcessGetObjectByHash (std::shared_ptr< protocol::TMGetObjectByHash > const &m)
beast::Journal const & pJournal () const
std::shared_ptr< PeerFinder::Slot > const & slot ()
void stop () override
void sendTxQueue () override
 Send aggregated transactions' hashes.
void addTxQueue (uint256 const &hash) override
 Add transaction's hash to the transactions' hashes queue.
void removeTxQueue (uint256 const &hash) override
 Remove transaction's hash from the transactions' hashes queue.
template<class FwdIt, class = std::enable_if_t< std::is_same_v<typename std::iterator_traits<FwdIt>::value_type, PeerFinder::Endpoint>>>
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 xrpld 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
void fail (std::string const &reason)
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 uncompressedSize, 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 resetId ()

Protected Member Functions

void processGetObjectByHash (std::shared_ptr< protocol::TMGetObjectByHash > const &m)
 Process a generic-query TMGetObjectByHash message.
Resource::Charge currentFeeCharge () const
 Read-only accessor for the accumulated peer-message charge.

Static Protected Member Functions

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 actually performed.

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)
void close ()
void gracefulClose ()
void setTimer ()
void cancelTimer () noexcept
void onTimer (boost::system::error_code const &ec)
void onShutdown (error_code ec)
void doAccept ()
std::string name () const
std::string domain () const
void doProtocolStart ()
void onReadMessage (error_code ec, std::size_t bytesTransferred)
void onWriteMessage (error_code ec, std::size_t bytesTransferred)
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::scoped_lock< 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

std::shared_ptr< MessagelastSentMessage_
Applicationapp_
id_t const id_
std::string fingerprint_
std::string prefix_
beast::WrappedSink sink_
beast::WrappedSink pSink_
beast::Journal const journal_
beast::Journal const pJournal_
std::unique_ptr< stream_typestreamPtr_
socket_typesocket_
stream_typestream_
boost::asio::strand< boost::asio::executor > strand_
waitable_timer timer_
beast::IP::Endpoint const remoteAddress_
OverlayImploverlay_
bool const inbound_
ProtocolVersion protocol_
std::atomic< Trackingtracking_
clock_type::time_point trackingTime_
bool detaching_ = false
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 lastStatus_
Resource::Consumer usage_
ChargeWithContext fee_
std::atomic< bool > chargeDisconnectFired_ {false}
std::shared_ptr< PeerFinder::Slot > const slot_
boost::beast::multi_buffer readBuffer_
http_request_type request_
http_response_type response_
boost::beast::http::fields const & headers_
std::queue< std::shared_ptr< Message > > sendQueue_
bool gracefulClose_ = false
int largeSendq_ = 0
std::unique_ptr< LoadEventloadEvent_
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_

Static Private Attributes

static Peer::id_t id = 0

Detailed Description

Test peer that captures sent messages for verification.

Definition at line 59 of file TMGetObjectByHash_test.cpp.

Member Typedef Documentation

◆ clock_type

Definition at line 40 of file PeerImp.h.

◆ error_code

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

Definition at line 41 of file PeerImp.h.

◆ socket_type

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

Definition at line 42 of file PeerImp.h.

◆ middle_type

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

Definition at line 43 of file PeerImp.h.

◆ stream_type

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

Definition at line 44 of file PeerImp.h.

◆ address_type

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

Definition at line 45 of file PeerImp.h.

◆ endpoint_type

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

Definition at line 46 of file PeerImp.h.

◆ waitable_timer

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

Definition at line 47 of file PeerImp.h.

◆ Compressed

Definition at line 48 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 37 of file PeerImp.h.

Constructor & Destructor Documentation

◆ PeerTest()

xrpl::test::TMGetObjectByHash_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< TMGetObjectByHash_test::stream_type > && streamPtr,
OverlayImpl & overlay )

Definition at line 62 of file TMGetObjectByHash_test.cpp.

◆ ~PeerTest()

xrpl::test::TMGetObjectByHash_test::PeerTest::~PeerTest ( )
overridedefault

Member Function Documentation

◆ run()

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

Reimplemented from xrpl::PeerImp.

Definition at line 87 of file TMGetObjectByHash_test.cpp.

◆ send()

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

Reimplemented from xrpl::PeerImp.

Definition at line 92 of file TMGetObjectByHash_test.cpp.

◆ getLastSentMessage()

std::shared_ptr< Message > xrpl::test::TMGetObjectByHash_test::PeerTest::getLastSentMessage ( ) const

Definition at line 98 of file TMGetObjectByHash_test.cpp.

◆ runProcessGetObjectByHash()

void xrpl::test::TMGetObjectByHash_test::PeerTest::runProcessGetObjectByHash ( std::shared_ptr< protocol::TMGetObjectByHash > const & m)

Definition at line 109 of file TMGetObjectByHash_test.cpp.

◆ resetId()

void xrpl::test::TMGetObjectByHash_test::PeerTest::resetId ( )
static

Definition at line 115 of file TMGetObjectByHash_test.cpp.

◆ pJournal()

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

Definition at line 251 of file PeerImp.h.

◆ slot()

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

Definition at line 257 of file PeerImp.h.

◆ stop()

void xrpl::PeerImp::stop ( )
overridevirtualinherited

Implements xrpl::OverlayImpl::Child.

Definition at line 256 of file PeerImp.cpp.

◆ sendTxQueue()

void xrpl::PeerImp::sendTxQueue ( )
overridevirtualinherited

Send aggregated transactions' hashes.

Implements xrpl::Peer.

Definition at line 331 of file PeerImp.cpp.

◆ addTxQueue()

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

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

Parameters
hashtransaction's hash

Implements xrpl::Peer.

Reimplemented in xrpl::test::tx_reduce_relay_test::PeerTest.

Definition at line 347 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 362 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 761 of file PeerImp.h.

◆ getRemoteAddress()

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

Implements xrpl::Peer.

Definition at line 302 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 371 of file PeerImp.cpp.

◆ id()

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

Implements xrpl::Peer.

Definition at line 315 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 397 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 406 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 1998 of file PeerImp.cpp.

◆ checkTracking() [2/2]

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

Definition at line 2017 of file PeerImp.cpp.

◆ getNodePublic()

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

Implements xrpl::Peer.

Definition at line 337 of file PeerImp.h.

◆ getVersion()

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

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

Definition at line 412 of file PeerImp.cpp.

◆ uptime()

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

Definition at line 348 of file PeerImp.h.

◆ json()

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

Implements xrpl::Peer.

Definition at line 420 of file PeerImp.cpp.

◆ supportsFeature()

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

Implements xrpl::Peer.

Definition at line 534 of file PeerImp.cpp.

◆ publisherListSequence()

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

Implements xrpl::Peer.

Definition at line 360 of file PeerImp.h.

◆ setPublisherListSequence()

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

Implements xrpl::Peer.

Definition at line 371 of file PeerImp.h.

◆ getClosedLedgerHash()

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

Implements xrpl::Peer.

Definition at line 383 of file PeerImp.h.

◆ hasLedger()

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

Implements xrpl::Peer.

Definition at line 551 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 565 of file PeerImp.cpp.

◆ hasTxSet()

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

Implements xrpl::Peer.

Definition at line 574 of file PeerImp.cpp.

◆ cycleStatus()

void xrpl::PeerImp::cycleStatus ( )
overridevirtualinherited

Implements xrpl::Peer.

Definition at line 581 of file PeerImp.cpp.

◆ hasRange()

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

Implements xrpl::Peer.

Definition at line 591 of file PeerImp.cpp.

◆ getScore()

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

Implements xrpl::Peer.

Definition at line 3507 of file PeerImp.cpp.

◆ isHighLatency()

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

Implements xrpl::Peer.

Definition at line 3549 of file PeerImp.cpp.

◆ fail() [1/2]

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

Definition at line 617 of file PeerImp.cpp.

◆ fail() [2/2]

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

Definition at line 630 of file PeerImp.cpp.

◆ compressionEnabled()

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

Implements xrpl::Peer.

Definition at line 414 of file PeerImp.h.

◆ txReduceRelayEnabled()

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

Implements xrpl::Peer.

Definition at line 420 of file PeerImp.h.

◆ close()

void xrpl::PeerImp::close ( )
privateinherited

Definition at line 600 of file PeerImp.cpp.

◆ gracefulClose()

void xrpl::PeerImp::gracefulClose ( )
privateinherited

Definition at line 642 of file PeerImp.cpp.

◆ setTimer()

void xrpl::PeerImp::setTimer ( )
privateinherited

Definition at line 657 of file PeerImp.cpp.

◆ cancelTimer()

void xrpl::PeerImp::cancelTimer ( )
privatenoexceptinherited

Definition at line 674 of file PeerImp.cpp.

◆ makePrefix()

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

Definition at line 689 of file PeerImp.cpp.

◆ onTimer()

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

Definition at line 697 of file PeerImp.cpp.

◆ onShutdown()

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

Definition at line 757 of file PeerImp.cpp.

◆ doAccept()

void xrpl::PeerImp::doAccept ( )
privateinherited

Definition at line 783 of file PeerImp.cpp.

◆ name()

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

Definition at line 857 of file PeerImp.cpp.

◆ domain()

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

Definition at line 864 of file PeerImp.cpp.

◆ doProtocolStart()

void xrpl::PeerImp::doProtocolStart ( )
privateinherited

Definition at line 874 of file PeerImp.cpp.

◆ onReadMessage()

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

Definition at line 912 of file PeerImp.cpp.

◆ onWriteMessage()

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

Definition at line 986 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 1285 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 2653 of file PeerImp.cpp.

◆ fingerprint()

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

Implements xrpl::Peer.

Definition at line 504 of file PeerImp.h.

◆ prefix()

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

Definition at line 510 of file PeerImp.h.

◆ onMessageUnknown()

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

Definition at line 1040 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 uncompressedSize,
bool isCompressed )
inherited

Definition at line 1046 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 1086 of file PeerImp.cpp.

◆ onMessage() [1/21]

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

Definition at line 1093 of file PeerImp.cpp.

◆ onMessage() [2/21]

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

Definition at line 1112 of file PeerImp.cpp.

◆ onMessage() [3/21]

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

Definition at line 1153 of file PeerImp.cpp.

◆ onMessage() [4/21]

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

Definition at line 1222 of file PeerImp.cpp.

◆ onMessage() [5/21]

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

Definition at line 1279 of file PeerImp.cpp.

◆ onMessage() [6/21]

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

Definition at line 1415 of file PeerImp.cpp.

◆ onMessage() [7/21]

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

Definition at line 1625 of file PeerImp.cpp.

◆ onMessage() [8/21]

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

Definition at line 1720 of file PeerImp.cpp.

◆ onMessage() [9/21]

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

Definition at line 1825 of file PeerImp.cpp.

◆ onMessage() [10/21]

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

Definition at line 2038 of file PeerImp.cpp.

◆ onMessage() [11/21]

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

Definition at line 2258 of file PeerImp.cpp.

◆ onMessage() [12/21]

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

Definition at line 2282 of file PeerImp.cpp.

◆ onMessage() [13/21]

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

Definition at line 2315 of file PeerImp.cpp.

◆ onMessage() [14/21]

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

Definition at line 2421 of file PeerImp.cpp.

◆ onMessage() [15/21]

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

Definition at line 2636 of file PeerImp.cpp.

◆ onMessage() [16/21]

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

Definition at line 2699 of file PeerImp.cpp.

◆ onMessage() [17/21]

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

Definition at line 2723 of file PeerImp.cpp.

◆ onMessage() [18/21]

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

Definition at line 1525 of file PeerImp.cpp.

◆ onMessage() [19/21]

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

Definition at line 1560 of file PeerImp.cpp.

◆ onMessage() [20/21]

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

Definition at line 1575 of file PeerImp.cpp.

◆ onMessage() [21/21]

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

Definition at line 1610 of file PeerImp.cpp.

◆ addLedger()

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

Definition at line 2766 of file PeerImp.cpp.

◆ doFetchPack()

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

Definition at line 2779 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 2063 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 2812 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 2864 of file PeerImp.cpp.

◆ checkPropose()

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

Definition at line 2997 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 3045 of file PeerImp.cpp.

◆ sendLedgerBase()

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

Definition at line 3136 of file PeerImp.cpp.

◆ getLedger()

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

Definition at line 3173 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 3257 of file PeerImp.cpp.

◆ processLedgerRequest()

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

Definition at line 3289 of file PeerImp.cpp.

◆ processGetObjectByHash()

void xrpl::PeerImp::processGetObjectByHash ( std::shared_ptr< protocol::TMGetObjectByHash > const & m)
protectedinherited

Process a generic-query TMGetObjectByHash message.

Dispatched from onMessage(TMGetObjectByHash) to the JobQueue (JtLedgerReq) so synchronous NodeStore lookups do not block the peer's I/O strand. Caps iteration at Tuning::kHardMaxReplyNodes regardless of hit/miss outcome and applies differential pricing via computeGetObjectByHashFee() after the fetch loop completes.

Parameters
mThe protocol message containing requested object hashes.

Definition at line 2573 of file PeerImp.cpp.

◆ computeGetObjectByHashFee()

Resource::Charge xrpl::PeerImp::computeGetObjectByHashFee ( int const requested,
int const found )
staticprotectedinherited

Compute the per-message resource charge for a TMGetObjectByHash request based on how much work was actually performed.

The charge has three components on top of the base Resource::kFeeModerateBurdenPeer:

  • per-hit lookup cost (cheap; usually served from cache)
  • per-miss lookup cost (expensive node store seeks)
  • request-size band surcharge (escalates abusive batch sizes)

The first Tuning::kFreeObjectsPerRequest objects are free so that legitimate InboundLedger::getNeededHashes() traffic (at most 8 objects) is unaffected.

Parameters
requestedNumber of objects requested by the message. This value is used for request-size pricing and may exceed Tuning::kHardMaxReplyNodes when this helper is called directly, even though processing caps the iterations to Tuning::kHardMaxReplyNodes.
foundNumber of objects successfully returned in the reply.
Returns
A Resource::Charge whose cost reflects the work performed.

Definition at line 3481 of file PeerImp.cpp.

◆ currentFeeCharge()

Resource::Charge xrpl::PeerImp::currentFeeCharge ( ) const
protectedinherited

Read-only accessor for the accumulated peer-message charge.

Exposed at protected scope so test subclasses can verify the oversized-request rejection path (Layer 1) without invoking the full JobQueue handler. Production callers should never read this back — the value is consumed by charge()/disconnect() internally.

Returns
The current Resource::Charge accumulated on fee_.

Definition at line 690 of file PeerImp.h.

Member Data Documentation

◆ id

Peer::id_t xrpl::test::TMGetObjectByHash_test::PeerTest::id = 0
staticprivate

Definition at line 121 of file TMGetObjectByHash_test.cpp.

◆ lastSentMessage_

std::shared_ptr<Message> xrpl::test::TMGetObjectByHash_test::PeerTest::lastSentMessage_
private

Definition at line 122 of file TMGetObjectByHash_test.cpp.

◆ app_

Application& xrpl::PeerImp::app_
privateinherited

Definition at line 50 of file PeerImp.h.

◆ id_

id_t const xrpl::PeerImp::id_
privateinherited

Definition at line 51 of file PeerImp.h.

◆ fingerprint_

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

Definition at line 52 of file PeerImp.h.

◆ prefix_

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

Definition at line 53 of file PeerImp.h.

◆ sink_

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

Definition at line 54 of file PeerImp.h.

◆ pSink_

beast::WrappedSink xrpl::PeerImp::pSink_
privateinherited

Definition at line 55 of file PeerImp.h.

◆ journal_

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

Definition at line 56 of file PeerImp.h.

◆ pJournal_

beast::Journal const xrpl::PeerImp::pJournal_
privateinherited

Definition at line 57 of file PeerImp.h.

◆ streamPtr_

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

Definition at line 58 of file PeerImp.h.

◆ socket_

socket_type& xrpl::PeerImp::socket_
privateinherited

Definition at line 59 of file PeerImp.h.

◆ stream_

stream_type& xrpl::PeerImp::stream_
privateinherited

Definition at line 60 of file PeerImp.h.

◆ strand_

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

Definition at line 61 of file PeerImp.h.

◆ timer_

waitable_timer xrpl::PeerImp::timer_
privateinherited

Definition at line 62 of file PeerImp.h.

◆ remoteAddress_

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

Definition at line 66 of file PeerImp.h.

◆ overlay_

OverlayImpl& xrpl::PeerImp::overlay_
privateinherited

Definition at line 70 of file PeerImp.h.

◆ inbound_

bool const xrpl::PeerImp::inbound_
privateinherited

Definition at line 71 of file PeerImp.h.

◆ protocol_

ProtocolVersion xrpl::PeerImp::protocol_
privateinherited

Definition at line 74 of file PeerImp.h.

◆ tracking_

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

Definition at line 76 of file PeerImp.h.

◆ trackingTime_

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

Definition at line 77 of file PeerImp.h.

◆ detaching_

bool xrpl::PeerImp::detaching_ = false
privateinherited

Definition at line 78 of file PeerImp.h.

◆ publicKey_

PublicKey const xrpl::PeerImp::publicKey_
privateinherited

Definition at line 80 of file PeerImp.h.

◆ name_

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

Definition at line 81 of file PeerImp.h.

◆ nameMutex_

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

Definition at line 82 of file PeerImp.h.

◆ minLedger_

LedgerIndex xrpl::PeerImp::minLedger_ = 0
privateinherited

Definition at line 86 of file PeerImp.h.

◆ maxLedger_

LedgerIndex xrpl::PeerImp::maxLedger_ = 0
privateinherited

Definition at line 87 of file PeerImp.h.

◆ closedLedgerHash_

uint256 xrpl::PeerImp::closedLedgerHash_
privateinherited

Definition at line 88 of file PeerImp.h.

◆ previousLedgerHash_

uint256 xrpl::PeerImp::previousLedgerHash_
privateinherited

Definition at line 89 of file PeerImp.h.

◆ recentLedgers_

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

Definition at line 91 of file PeerImp.h.

◆ recentTxSets_

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

Definition at line 92 of file PeerImp.h.

◆ latency_

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

Definition at line 94 of file PeerImp.h.

◆ lastPingSeq_

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

Definition at line 95 of file PeerImp.h.

◆ lastPingTime_

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

Definition at line 96 of file PeerImp.h.

◆ creationTime_

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

Definition at line 97 of file PeerImp.h.

◆ squelch_

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

Definition at line 99 of file PeerImp.h.

◆ recentLock_

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

Definition at line 146 of file PeerImp.h.

◆ lastStatus_

protocol::TMStatusChange xrpl::PeerImp::lastStatus_
privateinherited

Definition at line 147 of file PeerImp.h.

◆ usage_

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

Definition at line 148 of file PeerImp.h.

◆ fee_

ChargeWithContext xrpl::PeerImp::fee_
privateinherited

Definition at line 149 of file PeerImp.h.

◆ chargeDisconnectFired_

std::atomic<bool> xrpl::PeerImp::chargeDisconnectFired_ {false}
privateinherited

Definition at line 155 of file PeerImp.h.

◆ slot_

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

Definition at line 156 of file PeerImp.h.

◆ readBuffer_

boost::beast::multi_buffer xrpl::PeerImp::readBuffer_
privateinherited

Definition at line 157 of file PeerImp.h.

◆ request_

http_request_type xrpl::PeerImp::request_
privateinherited

Definition at line 158 of file PeerImp.h.

◆ response_

http_response_type xrpl::PeerImp::response_
privateinherited

Definition at line 159 of file PeerImp.h.

◆ headers_

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

Definition at line 160 of file PeerImp.h.

◆ sendQueue_

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

Definition at line 161 of file PeerImp.h.

◆ gracefulClose_

bool xrpl::PeerImp::gracefulClose_ = false
privateinherited

Definition at line 162 of file PeerImp.h.

◆ largeSendq_

int xrpl::PeerImp::largeSendq_ = 0
privateinherited

Definition at line 163 of file PeerImp.h.

◆ loadEvent_

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

Definition at line 164 of file PeerImp.h.

◆ publisherListSequences_

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

Definition at line 167 of file PeerImp.h.

◆ compressionEnabled_

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

Definition at line 169 of file PeerImp.h.

◆ txQueue_

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

Definition at line 174 of file PeerImp.h.

◆ txReduceRelayEnabled_

bool xrpl::PeerImp::txReduceRelayEnabled_ = false
privateinherited

Definition at line 176 of file PeerImp.h.

◆ ledgerReplayEnabled_

bool xrpl::PeerImp::ledgerReplayEnabled_ = false
privateinherited

Definition at line 178 of file PeerImp.h.

◆ ledgerReplayMsgHandler_

LedgerReplayMsgHandler xrpl::PeerImp::ledgerReplayMsgHandler_
privateinherited

Definition at line 179 of file PeerImp.h.

◆ sent

Metrics xrpl::PeerImp::sent
inherited

Definition at line 212 of file PeerImp.h.

◆ recv

Metrics xrpl::PeerImp::recv
inherited

Definition at line 213 of file PeerImp.h.

◆ [struct]

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