rippled
Loading...
Searching...
No Matches
PeerImp.h
1#pragma once
2
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>
9
10#include <xrpl/basics/Log.h>
11#include <xrpl/basics/UnorderedContainers.h>
12#include <xrpl/beast/utility/WrappedSink.h>
13#include <xrpl/core/HashRouter.h>
14#include <xrpl/protocol/Protocol.h>
15#include <xrpl/protocol/STTx.h>
16#include <xrpl/protocol/STValidation.h>
17#include <xrpl/resource/Fees.h>
18
19#include <boost/circular_buffer.hpp>
20#include <boost/endian/conversion.hpp>
21#include <boost/thread/shared_mutex.hpp>
22
23#include <atomic>
24#include <cstdint>
25#include <optional>
26#include <queue>
27
28namespace xrpl {
29
30struct ValidatorBlobInfo;
31class SHAMap;
32
95class PeerImp : public Peer, public std::enable_shared_from_this<PeerImp>, public OverlayImpl::Child
96{
97public:
100
101private:
103 using error_code = boost::system::error_code;
104 using socket_type = boost::asio::ip::tcp::socket;
105 using middle_type = boost::beast::tcp_stream;
106 using stream_type = boost::beast::ssl_stream<middle_type>;
107 using address_type = boost::asio::ip::address;
108 using endpoint_type = boost::asio::ip::tcp::endpoint;
109 using waitable_timer = boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
111
113 id_t const id_;
123 boost::asio::strand<boost::asio::executor> strand_;
124
125 // Multi-purpose timer for peer activity monitoring and shutdown safety
127
128 // Updated at each stage of the connection process to reflect
129 // the current conditions as closely as possible.
131
132 // These are up here to prevent warnings about order of initializations
133 //
135 bool const inbound_;
136
137 // Protocol version to use for this link
139
141 clock_type::time_point trackingTime_;
142 // Node public key of peer.
146
147 // The indices of the smallest and largest ledgers this peer has available
148 //
153
154 boost::circular_buffer<uint256> recentLedgers_{128};
155 boost::circular_buffer<uint256> recentTxSets_{128};
156
159 clock_type::time_point lastPingTime_;
160 clock_type::time_point const creationTime_;
161
163
164 // Notes on thread locking:
165 //
166 // During an audit it was noted that some member variables that looked
167 // like they need thread protection were not receiving it. And, indeed,
168 // that was correct. But the multi-phase initialization of PeerImp
169 // makes such an audit difficult. A further audit suggests that the
170 // locking is now protecting variables that don't need it. We're
171 // leaving that locking in place (for now) as a form of future proofing.
172 //
173 // Here are the variables that appear to need locking currently:
174 //
175 // o closedLedgerHash_
176 // o previousLedgerHash_
177 // o minLedger_
178 // o maxLedger_
179 // o recentLedgers_
180 // o recentTxSets_
181 // o trackingTime_
182 // o latency_
183 //
184 // The following variables are being protected preemptively:
185 //
186 // o name_
187 // o last_status_
188 //
189 // June 2019
190
192 {
195
196 void
198 {
199 XRPL_ASSERT(f >= fee, "xrpl::PeerImp::ChargeWithContext::update : fee increases");
200 fee = f;
201 if (!context.empty())
202 {
203 context += " ";
204 }
205 context += add;
206 }
207 };
208
210 protocol::TMStatusChange last_status_;
214 boost::beast::multi_buffer read_buffer_;
217 boost::beast::http::fields const& headers_;
219
220 // Primary shutdown flag set when shutdown is requested
221 bool shutdown_ = false;
222
223 // SSL shutdown coordination flag
224 bool shutdownStarted_ = false;
225
226 // Indicates a read operation is currently pending
227 bool readPending_ = false;
228
229 // Indicates a write operation is currently pending
230 bool writePending_ = false;
231
234 // The highest sequence of each PublisherList that has
235 // been sent to or received from this peer.
237
239
240 // Queue of transactions' hashes that have not been
241 // relayed. The hashes are sent once a second to a peer
242 // and the peer requests missing transactions from the node.
244 // true if tx reduce-relay feature is enabled on the peer.
246
249
250 friend class OverlayImpl;
251
253 {
254 public:
255 Metrics() = default;
256 Metrics(Metrics const&) = delete;
257 Metrics&
258 operator=(Metrics const&) = delete;
259 Metrics(Metrics&&) = delete;
260 Metrics&
261 operator=(Metrics&&) = delete;
262
263 void
266 average_bytes() const;
268 total_bytes() const;
269
270 private:
272 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
273 clock_type::time_point intervalStart_{clock_type::now()};
277 };
278
279 struct
280 {
284
285public:
286 PeerImp(PeerImp const&) = delete;
287 PeerImp&
288 operator=(PeerImp const&) = delete;
289
291 PeerImp(
292 Application& app,
293 id_t id,
295 http_request_type&& request,
296 PublicKey const& publicKey,
298 Resource::Consumer consumer,
299 std::unique_ptr<stream_type>&& stream_ptr,
300 OverlayImpl& overlay);
301
303 // VFALCO legacyPublicKey should be implied by the Slot
304 template <class Buffers>
305 PeerImp(
306 Application& app,
307 std::unique_ptr<stream_type>&& stream_ptr,
308 Buffers const& buffers,
310 http_response_type&& response,
311 Resource::Consumer usage,
312 PublicKey const& publicKey,
314 id_t id,
315 OverlayImpl& overlay);
316
317 virtual ~PeerImp();
318
319 beast::Journal const&
320 pJournal() const
321 {
322 return p_journal_;
323 }
324
327 {
328 return slot_;
329 }
330
331 // Work-around for calling shared_from_this in constructors
332 virtual void
333 run();
334
335 // Called when Overlay gets a stop request.
336 void
337 stop() override;
338
339 //
340 // Network
341 //
342
343 void
344 send(std::shared_ptr<Message> const& m) override;
345
347 void
348 sendTxQueue() override;
349
353 void
354 addTxQueue(uint256 const& hash) override;
355
359 void
360 removeTxQueue(uint256 const& hash) override;
361
363 template <
364 class FwdIt,
365 class = typename std::enable_if_t<
367 void
368 sendEndpoints(FwdIt first, FwdIt last);
369
371 getRemoteAddress() const override
372 {
373 return remote_address_;
374 }
375
376 void
377 charge(Resource::Charge const& fee, std::string const& context) override;
378
379 //
380 // Identity
381 //
382
384 id() const override
385 {
386 return id_;
387 }
388
390 bool
391 crawl() const;
392
393 bool
394 cluster() const override;
395
399 void
400 checkTracking(std::uint32_t validationSeq);
401
402 void
404
405 PublicKey const&
406 getNodePublic() const override
407 {
408 return publicKey_;
409 }
410
413 getVersion() const;
414
415 // Return the connection elapsed time.
416 clock_type::duration
417 uptime() const
418 {
420 }
421
423 json() override;
424
425 bool
426 supportsFeature(ProtocolFeature f) const override;
427
429 publisherListSequence(PublicKey const& pubKey) const override
430 {
432
433 auto iter = publisherListSequences_.find(pubKey);
434 if (iter != publisherListSequences_.end())
435 return iter->second;
436 return {};
437 }
438
439 void
440 setPublisherListSequence(PublicKey const& pubKey, std::size_t const seq) override
441 {
443
444 publisherListSequences_[pubKey] = seq;
445 }
446
447 //
448 // Ledger
449 //
450
451 uint256 const&
452 getClosedLedgerHash() const override
453 {
454 return closedLedgerHash_;
455 }
456
457 bool
458 hasLedger(uint256 const& hash, std::uint32_t seq) const override;
459
460 void
461 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
462
463 bool
464 hasTxSet(uint256 const& hash) const override;
465
466 void
467 cycleStatus() override;
468
469 bool
470 hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
471
472 // Called to determine our priority for querying
473 int
474 getScore(bool haveItem) const override;
475
476 bool
477 isHighLatency() const override;
478
479 bool
480 compressionEnabled() const override
481 {
482 return compressionEnabled_ == Compressed::On;
483 }
484
485 bool
486 txReduceRelayEnabled() const override
487 {
489 }
490
491private:
506 void
507 fail(std::string const& name, error_code ec);
508
522 void
523 fail(std::string const& reason);
524
534 void
535 shutdown();
536
546 void
548
561 void
563
575 void
576 close();
577
587 void
589
600 void
601 onTimer(error_code const& ec);
602
609 void
610 cancelTimer() noexcept;
611
612 static std::string
613 makePrefix(std::string const& fingerprint);
614
615 void
616 doAccept();
617
618 std::string
619 name() const;
620
621 std::string
622 domain() const;
623
624 //
625 // protocol message loop
626 //
627
628 // Starts the protocol message loop
629 void
631
632 // Called when protocol message bytes are received
633 void
634 onReadMessage(error_code ec, std::size_t bytes_transferred);
635
636 // Called when protocol messages bytes are sent
637 void
638 onWriteMessage(error_code ec, std::size_t bytes_transferred);
639
652 void
653 handleTransaction(std::shared_ptr<protocol::TMTransaction> const& m, bool eraseTxQueue, bool batch);
654
660 void
661 handleHaveTransactions(std::shared_ptr<protocol::TMHaveTransactions> const& m);
662
663 std::string const&
664 fingerprint() const override
665 {
666 return fingerprint_;
667 }
668
669 std::string const&
670 prefix() const
671 {
672 return prefix_;
673 }
674
675public:
676 //--------------------------------------------------------------------------
677 //
678 // ProtocolStream
679 //
680 //--------------------------------------------------------------------------
681
682 void
684
685 void
687 std::uint16_t type,
689 std::size_t size,
690 std::size_t uncompressed_size,
691 bool isCompressed);
692
693 void
695
696 void
698 void
700 void
702 void
704 void
706 void
708 void
710 void
712 void
714 void
716 void
718 void
720 void
722 void
724 void
726 void
728 void
730 void
732 void
734 void
736 void
738
739private:
740 //--------------------------------------------------------------------------
741 // lockedRecentLock is passed as a reminder to callers that recentLock_
742 // must be locked.
743 void
744 addLedger(uint256 const& hash, std::lock_guard<std::mutex> const& lockedRecentLock);
745
746 void
748
749 void
751 std::string const& messageType,
752 std::string const& manifest,
753 std::uint32_t version,
754 std::vector<ValidatorBlobInfo> const& blobs);
755
760 void
762
763 void
764 checkTransaction(HashRouterFlags flags, bool checkSignature, std::shared_ptr<STTx const> const& stx, bool batch);
765
766 void
767 checkPropose(bool isTrusted, std::shared_ptr<protocol::TMProposeSet> const& packet, RCLCxPeerPos peerPos);
768
769 void
772 uint256 const& key,
774
775 void
776 sendLedgerBase(std::shared_ptr<Ledger const> const& ledger, protocol::TMLedgerData& ledgerData);
777
780
783
784 void
786};
787
788//------------------------------------------------------------------------------
789
790template <class Buffers>
792 Application& app,
793 std::unique_ptr<stream_type>&& stream_ptr,
794 Buffers const& buffers,
796 http_response_type&& response,
797 Resource::Consumer usage,
798 PublicKey const& publicKey,
800 id_t id,
801 OverlayImpl& overlay)
802 : Child(overlay)
803 , app_(app)
804 , id_(id)
805 , fingerprint_(getFingerprint(slot->remote_endpoint(), publicKey, to_string(id_)))
806 , prefix_(makePrefix(fingerprint_))
807 , sink_(app_.journal("Peer"), prefix_)
808 , p_sink_(app_.journal("Protocol"), prefix_)
809 , journal_(sink_)
810 , p_journal_(p_sink_)
811 , stream_ptr_(std::move(stream_ptr))
812 , socket_(stream_ptr_->next_layer().socket())
813 , stream_(*stream_ptr_)
814 , strand_(boost::asio::make_strand(socket_.get_executor()))
815 , timer_(waitable_timer{socket_.get_executor()})
816 , remote_address_(slot->remote_endpoint())
817 , overlay_(overlay)
818 , inbound_(false)
819 , protocol_(protocol)
820 , tracking_(Tracking::unknown)
821 , trackingTime_(clock_type::now())
822 , publicKey_(publicKey)
823 , lastPingTime_(clock_type::now())
824 , creationTime_(clock_type::now())
825 , squelch_(app_.journal("Squelch"))
826 , usage_(usage)
827 , fee_{Resource::feeTrivialPeer}
828 , slot_(std::move(slot))
829 , response_(std::move(response))
830 , headers_(response_)
831 , compressionEnabled_(
832 peerFeatureEnabled(headers_, FEATURE_COMPR, "lz4", app_.config().COMPRESSION) ? Compressed::On
833 : Compressed::Off)
834 , txReduceRelayEnabled_(peerFeatureEnabled(headers_, FEATURE_TXRR, app_.config().TX_REDUCE_RELAY_ENABLE))
835 , ledgerReplayEnabled_(peerFeatureEnabled(headers_, FEATURE_LEDGER_REPLAY, app_.config().LEDGER_REPLAY))
836 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
837{
838 read_buffer_.commit(boost::asio::buffer_copy(read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
839 JLOG(journal_.info()) << "compression enabled " << (compressionEnabled_ == Compressed::On)
840 << " vp reduce-relay base squelch enabled "
843 << " tx reduce-relay enabled " << txReduceRelayEnabled_ << " on " << remote_address_ << " "
844 << id_;
845}
846
847template <class FwdIt, class>
848void
849PeerImp::sendEndpoints(FwdIt first, FwdIt last)
850{
851 protocol::TMEndpoints tm;
852
853 while (first != last)
854 {
855 auto& tme2(*tm.add_endpoints_v2());
856 tme2.set_endpoint(first->address.to_string());
857 tme2.set_hops(first->hops);
858 first++;
859 }
860 tm.set_version(2);
861
862 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
863}
864
865} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
A version-independent IP address and port combination.
Definition IPEndpoint.h:18
A generic endpoint for log messages.
Definition Journal.h:40
Stream info() const
Definition Journal.h:306
Wraps a Journal::Sink to prefix its output with a string.
Definition WrappedSink.h:14
virtual Config & config()=0
bool VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE
Definition Config.h:229
std::shared_mutex mutex_
Definition PeerImp.h:271
std::uint64_t rollingAvgBytes_
Definition PeerImp.h:276
clock_type::time_point intervalStart_
Definition PeerImp.h:273
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition PeerImp.h:272
Metrics(Metrics const &)=delete
Metrics & operator=(Metrics const &)=delete
Metrics & operator=(Metrics &&)=delete
Metrics(Metrics &&)=delete
std::uint64_t average_bytes() const
Definition PeerImp.cpp:3279
std::uint64_t total_bytes() const
Definition PeerImp.cpp:3286
std::uint64_t accumBytes_
Definition PeerImp.h:275
void add_message(std::uint64_t bytes)
Definition PeerImp.cpp:3255
std::uint64_t totalBytes_
Definition PeerImp.h:274
This class manages established peer-to-peer connections, handles message exchange,...
Definition PeerImp.h:96
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition PeerImp.cpp:1872
std::optional< std::chrono::milliseconds > latency_
Definition PeerImp.h:157
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition PeerImp.cpp:280
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition PeerImp.cpp:335
std::unique_ptr< LoadEvent > load_event_
Definition PeerImp.h:233
beast::Journal const p_journal_
Definition PeerImp.h:119
boost::asio::ip::tcp::endpoint endpoint_type
Definition PeerImp.h:108
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition PeerImp.cpp:1035
ProtocolVersion protocol_
Definition PeerImp.h:138
bool txReduceRelayEnabled_
Definition PeerImp.h:245
void checkTransaction(HashRouterFlags flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
Definition PeerImp.cpp:2643
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition PeerImp.h:326
void close()
Forcibly closes the underlying socket connection.
Definition PeerImp.cpp:611
boost::beast::tcp_stream middle_type
Definition PeerImp.h:105
bool readPending_
Definition PeerImp.h:227
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
Called from onMessage(TMTransaction(s)).
Definition PeerImp.cpp:1218
http_request_type request_
Definition PeerImp.h:215
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition PeerImp.cpp:296
beast::WrappedSink sink_
Definition PeerImp.h:116
std::string name() const
Definition PeerImp.cpp:804
bool txReduceRelayEnabled() const override
Definition PeerImp.h:486
std::shared_ptr< PeerFinder::Slot > const slot_
Definition PeerImp.h:213
boost::asio::ip::tcp::socket socket_type
Definition PeerImp.h:104
boost::beast::http::fields const & headers_
Definition PeerImp.h:217
Compressed compressionEnabled_
Definition PeerImp.h:238
void onTimer(error_code const &ec)
Handles the expiration of the peer activity timer.
Definition PeerImp.cpp:661
uint256 const & getClosedLedgerHash() const override
Definition PeerImp.h:452
boost::system::error_code error_code
Definition PeerImp.h:103
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition PeerImp.cpp:2549
PeerImp & operator=(PeerImp const &)=delete
void tryAsyncShutdown()
Attempts to perform a graceful SSL shutdown if conditions are met.
Definition PeerImp.cpp:552
LedgerIndex minLedger_
Definition PeerImp.h:149
std::string prefix_
Definition PeerImp.h:115
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition PeerImp.h:849
id_t const id_
Definition PeerImp.h:113
Metrics sent
Definition PeerImp.h:281
std::string const & fingerprint() const override
Definition PeerImp.h:664
void charge(Resource::Charge const &fee, std::string const &context) override
Adjust this peer's load balance based on the type of load imposed.
Definition PeerImp.cpp:306
bool ledgerReplayEnabled_
Definition PeerImp.h:247
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition PeerImp.cpp:263
uint256 closedLedgerHash_
Definition PeerImp.h:151
reduce_relay::Squelch< UptimeClock > squelch_
Definition PeerImp.h:162
stream_type & stream_
Definition PeerImp.h:122
PeerImp(PeerImp const &)=delete
void checkValidation(std::shared_ptr< STValidation > const &val, uint256 const &key, std::shared_ptr< protocol::TMValidation > const &packet)
Definition PeerImp.cpp:2810
void cycleStatus() override
Definition PeerImp.cpp:500
std::shared_mutex nameMutex_
Definition PeerImp.h:145
socket_type & socket_
Definition PeerImp.h:121
beast::IP::Endpoint const remote_address_
Definition PeerImp.h:130
int large_sendq_
Definition PeerImp.h:232
std::string domain() const
Definition PeerImp.cpp:811
std::atomic< Tracking > tracking_
Definition PeerImp.h:140
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition PeerImp.h:429
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition PeerImp.cpp:484
clock_type::duration uptime() const
Definition PeerImp.h:417
boost::asio::ip::address address_type
Definition PeerImp.h:107
LedgerIndex maxLedger_
Definition PeerImp.h:150
Application & app_
Definition PeerImp.h:112
PublicKey const publicKey_
Definition PeerImp.h:143
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)
Definition PeerImp.cpp:991
Json::Value json() override
Definition PeerImp.cpp:343
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition PeerImp.cpp:329
Metrics recv
Definition PeerImp.h:282
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition PeerImp.cpp:2775
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition PeerImp.cpp:933
virtual void run()
Definition PeerImp.cpp:129
OverlayImpl & overlay_
Definition PeerImp.h:134
std::queue< std::shared_ptr< Message > > send_queue_
Definition PeerImp.h:218
virtual ~PeerImp()
Definition PeerImp.cpp:106
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition PeerImp.cpp:2897
Peer::id_t id() const override
Definition PeerImp.h:384
static std::string makePrefix(std::string const &fingerprint)
Definition PeerImp.cpp:653
beast::Journal const & pJournal() const
Definition PeerImp.h:320
ChargeWithContext fee_
Definition PeerImp.h:212
void onShutdown(error_code ec)
Handles the completion of the asynchronous SSL shutdown.
Definition PeerImp.cpp:587
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...
Definition PeerImp.cpp:2443
beast::IP::Endpoint getRemoteAddress() const override
Definition PeerImp.h:371
void onMessageUnknown(std::uint16_t type)
Definition PeerImp.cpp:985
protocol::TMStatusChange last_status_
Definition PeerImp.h:210
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition PeerImp.cpp:854
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition PeerImp.h:440
bool compressionEnabled() const override
Definition PeerImp.h:480
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition PeerImp.cpp:3047
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition PeerImp.h:99
std::unique_ptr< stream_type > stream_ptr_
Definition PeerImp.h:120
clock_type::time_point const creationTime_
Definition PeerImp.h:160
struct xrpl::PeerImp::@22 metrics_
beast::WrappedSink p_sink_
Definition PeerImp.h:117
boost::beast::multi_buffer read_buffer_
Definition PeerImp.h:214
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition PeerImp.h:248
void send(std::shared_ptr< Message > const &m) override
Definition PeerImp.cpp:204
hash_set< uint256 > txQueue_
Definition PeerImp.h:243
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Definition PeerImp.cpp:2562
bool supportsFeature(ProtocolFeature f) const override
Definition PeerImp.cpp:454
void doProtocolStart()
Definition PeerImp.cpp:821
void shutdown()
Initiates the peer disconnection sequence.
Definition PeerImp.cpp:572
PublicKey const & getNodePublic() const override
Definition PeerImp.h:406
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition PeerImp.cpp:2932
bool const inbound_
Definition PeerImp.h:135
boost::asio::strand< boost::asio::executor > strand_
Definition PeerImp.h:123
waitable_timer timer_
Definition PeerImp.h:126
clock_type::time_point lastPingTime_
Definition PeerImp.h:159
boost::circular_buffer< uint256 > recentLedgers_
Definition PeerImp.h:154
int getScore(bool haveItem) const override
Definition PeerImp.cpp:3210
std::string name_
Definition PeerImp.h:144
bool hasTxSet(uint256 const &hash) const override
Definition PeerImp.cpp:493
bool writePending_
Definition PeerImp.h:230
http_response_type response_
Definition PeerImp.h:216
boost::circular_buffer< uint256 > recentTxSets_
Definition PeerImp.h:155
clock_type::time_point trackingTime_
Definition PeerImp.h:141
beast::Journal const journal_
Definition PeerImp.h:118
std::string fingerprint_
Definition PeerImp.h:114
bool isHighLatency() const override
Definition PeerImp.cpp:3248
void cancelTimer() noexcept
Cancels any pending wait on the peer activity timer.
Definition PeerImp.cpp:724
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition PeerImp.cpp:510
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition PeerImp.cpp:3015
uint256 previousLedgerHash_
Definition PeerImp.h:152
Resource::Consumer usage_
Definition PeerImp.h:211
bool shutdownStarted_
Definition PeerImp.h:224
std::optional< std::uint32_t > lastPingSeq_
Definition PeerImp.h:158
boost::beast::ssl_stream< middle_type > stream_type
Definition PeerImp.h:106
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition PeerImp.cpp:320
void stop() override
Definition PeerImp.cpp:184
void setTimer(std::chrono::seconds interval)
Sets and starts the peer timer.
Definition PeerImp.cpp:635
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
Definition PeerImp.cpp:1937
bool shutdown_
Definition PeerImp.h:221
std::string const & prefix() const
Definition PeerImp.h:670
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
Definition PeerImp.cpp:2594
void doAccept()
Definition PeerImp.cpp:738
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition PeerImp.h:236
void fail(std::string const &name, error_code ec)
Handles a failure associated with a specific error code.
Definition PeerImp.cpp:519
std::mutex recentLock_
Definition PeerImp.h:209
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition PeerImp.cpp:471
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition PeerImp.h:109
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition PeerImp.cpp:1028
Represents a peer connection in the overlay.
A public key.
Definition PublicKey.h:42
A peer's signed, proposed position for use in RCLConsensus.
A consumption charge.
Definition Charge.h:10
An endpoint that consumes resources.
Definition Consumer.h:16
Maintains squelching of relaying messages from validators.
Definition Squelch.h:19
T empty(T... args)
STL namespace.
Charge const feeTrivialPeer
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
Definition Handoff.h:14
static constexpr char FEATURE_COMPR[]
Definition Handshake.h:118
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:597
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition Handoff.h:12
bool peerFeatureEnabled(headers const &request, std::string const &feature, std::string value, bool config)
Check if a feature should be enabled for a peer.
Definition Handshake.h:168
std::string getFingerprint(beast::IP::Endpoint const &address, std::optional< PublicKey > const &publicKey=std::nullopt, std::optional< std::string > const &id=std::nullopt)
Definition PublicKey.h:241
HashRouterFlags
Definition HashRouter.h:14
@ manifest
Manifest.
static constexpr char FEATURE_LEDGER_REPLAY[]
Definition Handshake.h:124
static constexpr char FEATURE_VPRR[]
Definition Handshake.h:120
static constexpr char FEATURE_TXRR[]
Definition Handshake.h:122
Describes a connectable peer address along with some metadata.
void update(Resource::Charge f, std::string const &add)
Definition PeerImp.h:197