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/UnorderedContainers.h>
11#include <xrpl/beast/utility/WrappedSink.h>
12#include <xrpl/core/HashRouter.h>
13#include <xrpl/protocol/Protocol.h>
14#include <xrpl/protocol/STTx.h>
15#include <xrpl/protocol/STValidation.h>
16#include <xrpl/resource/Fees.h>
17
18#include <boost/circular_buffer.hpp>
19#include <boost/endian/conversion.hpp>
20#include <boost/thread/shared_mutex.hpp>
21
22#include <atomic>
23#include <cstdint>
24#include <optional>
25#include <queue>
26
27namespace xrpl {
28
29struct ValidatorBlobInfo;
30class SHAMap;
31
94class PeerImp : public Peer, public std::enable_shared_from_this<PeerImp>, public OverlayImpl::Child
95{
96public:
99
100private:
102 using error_code = boost::system::error_code;
103 using socket_type = boost::asio::ip::tcp::socket;
104 using middle_type = boost::beast::tcp_stream;
105 using stream_type = boost::beast::ssl_stream<middle_type>;
106 using address_type = boost::asio::ip::address;
107 using endpoint_type = boost::asio::ip::tcp::endpoint;
108 using waitable_timer = boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
110
112 id_t const id_;
122 boost::asio::strand<boost::asio::executor> strand_;
123
124 // Multi-purpose timer for peer activity monitoring and shutdown safety
126
127 // Updated at each stage of the connection process to reflect
128 // the current conditions as closely as possible.
130
131 // These are up here to prevent warnings about order of initializations
132 //
134 bool const inbound_;
135
136 // Protocol version to use for this link
138
140 clock_type::time_point trackingTime_;
141 // Node public key of peer.
145
146 // The indices of the smallest and largest ledgers this peer has available
147 //
152
153 boost::circular_buffer<uint256> recentLedgers_{128};
154 boost::circular_buffer<uint256> recentTxSets_{128};
155
158 clock_type::time_point lastPingTime_;
159 clock_type::time_point const creationTime_;
160
162
163 // Notes on thread locking:
164 //
165 // During an audit it was noted that some member variables that looked
166 // like they need thread protection were not receiving it. And, indeed,
167 // that was correct. But the multi-phase initialization of PeerImp
168 // makes such an audit difficult. A further audit suggests that the
169 // locking is now protecting variables that don't need it. We're
170 // leaving that locking in place (for now) as a form of future proofing.
171 //
172 // Here are the variables that appear to need locking currently:
173 //
174 // o closedLedgerHash_
175 // o previousLedgerHash_
176 // o minLedger_
177 // o maxLedger_
178 // o recentLedgers_
179 // o recentTxSets_
180 // o trackingTime_
181 // o latency_
182 //
183 // The following variables are being protected preemptively:
184 //
185 // o name_
186 // o last_status_
187 //
188 // June 2019
189
191 {
194
195 void
197 {
198 XRPL_ASSERT(f >= fee, "xrpl::PeerImp::ChargeWithContext::update : fee increases");
199 fee = f;
200 if (!context.empty())
201 {
202 context += " ";
203 }
204 context += add;
205 }
206 };
207
209 protocol::TMStatusChange last_status_;
213 boost::beast::multi_buffer read_buffer_;
216 boost::beast::http::fields const& headers_;
218
219 // Primary shutdown flag set when shutdown is requested
220 bool shutdown_ = false;
221
222 // SSL shutdown coordination flag
223 bool shutdownStarted_ = false;
224
225 // Indicates a read operation is currently pending
226 bool readPending_ = false;
227
228 // Indicates a write operation is currently pending
229 bool writePending_ = false;
230
233 // The highest sequence of each PublisherList that has
234 // been sent to or received from this peer.
236
238
239 // Queue of transactions' hashes that have not been
240 // relayed. The hashes are sent once a second to a peer
241 // and the peer requests missing transactions from the node.
243 // true if tx reduce-relay feature is enabled on the peer.
245
248
249 friend class OverlayImpl;
250
252 {
253 public:
254 Metrics() = default;
255 Metrics(Metrics const&) = delete;
256 Metrics&
257 operator=(Metrics const&) = delete;
258 Metrics(Metrics&&) = delete;
259 Metrics&
260 operator=(Metrics&&) = delete;
261
262 void
265 average_bytes() const;
267 total_bytes() const;
268
269 private:
271 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
272 clock_type::time_point intervalStart_{clock_type::now()};
276 };
277
278 struct
279 {
283
284public:
285 PeerImp(PeerImp const&) = delete;
286 PeerImp&
287 operator=(PeerImp const&) = delete;
288
290 PeerImp(
291 Application& app,
292 id_t id,
294 http_request_type&& request,
295 PublicKey const& publicKey,
297 Resource::Consumer consumer,
298 std::unique_ptr<stream_type>&& stream_ptr,
299 OverlayImpl& overlay);
300
302 // VFALCO legacyPublicKey should be implied by the Slot
303 template <class Buffers>
304 PeerImp(
305 Application& app,
306 std::unique_ptr<stream_type>&& stream_ptr,
307 Buffers const& buffers,
309 http_response_type&& response,
310 Resource::Consumer usage,
311 PublicKey const& publicKey,
313 id_t id,
314 OverlayImpl& overlay);
315
316 virtual ~PeerImp();
317
318 beast::Journal const&
319 pJournal() const
320 {
321 return p_journal_;
322 }
323
326 {
327 return slot_;
328 }
329
330 // Work-around for calling shared_from_this in constructors
331 virtual void
332 run();
333
334 // Called when Overlay gets a stop request.
335 void
336 stop() override;
337
338 //
339 // Network
340 //
341
342 void
343 send(std::shared_ptr<Message> const& m) override;
344
346 void
347 sendTxQueue() override;
348
352 void
353 addTxQueue(uint256 const& hash) override;
354
358 void
359 removeTxQueue(uint256 const& hash) override;
360
362 template <
363 class FwdIt,
364 class = typename std::enable_if_t<std::is_same<
366 PeerFinder::Endpoint>::value>>
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
654 std::shared_ptr<protocol::TMTransaction> const& m,
655 bool eraseTxQueue,
656 bool batch);
657
663 void
664 handleHaveTransactions(std::shared_ptr<protocol::TMHaveTransactions> const& m);
665
666 std::string const&
667 fingerprint() const override
668 {
669 return fingerprint_;
670 }
671
672 std::string const&
673 prefix() const
674 {
675 return prefix_;
676 }
677
678public:
679 //--------------------------------------------------------------------------
680 //
681 // ProtocolStream
682 //
683 //--------------------------------------------------------------------------
684
685 void
687
688 void
690 std::uint16_t type,
692 std::size_t size,
693 std::size_t uncompressed_size,
694 bool isCompressed);
695
696 void
698
699 void
701 void
703 void
705 void
707 void
709 void
711 void
713 void
715 void
717 void
719 void
721 void
723 void
725 void
727 void
729 void
731 void
733 void
735 void
737 void
739 void
741
742private:
743 //--------------------------------------------------------------------------
744 // lockedRecentLock is passed as a reminder to callers that recentLock_
745 // must be locked.
746 void
747 addLedger(uint256 const& hash, std::lock_guard<std::mutex> const& lockedRecentLock);
748
749 void
751
752 void
754 std::string const& messageType,
755 std::string const& manifest,
756 std::uint32_t version,
757 std::vector<ValidatorBlobInfo> const& blobs);
758
763 void
765
766 void
768 HashRouterFlags flags,
769 bool checkSignature,
771 bool batch);
772
773 void
775 bool isTrusted,
777 RCLCxPeerPos peerPos);
778
779 void
782 uint256 const& key,
784
785 void
786 sendLedgerBase(std::shared_ptr<Ledger const> const& ledger, protocol::TMLedgerData& ledgerData);
787
790
793
794 void
796};
797
798//------------------------------------------------------------------------------
799
800template <class Buffers>
802 Application& app,
803 std::unique_ptr<stream_type>&& stream_ptr,
804 Buffers const& buffers,
806 http_response_type&& response,
807 Resource::Consumer usage,
808 PublicKey const& publicKey,
810 id_t id,
811 OverlayImpl& overlay)
812 : Child(overlay)
813 , app_(app)
814 , id_(id)
815 , fingerprint_(getFingerprint(slot->remote_endpoint(), publicKey, to_string(id_)))
816 , prefix_(makePrefix(fingerprint_))
817 , sink_(app_.getJournal("Peer"), prefix_)
818 , p_sink_(app_.getJournal("Protocol"), prefix_)
819 , journal_(sink_)
820 , p_journal_(p_sink_)
821 , stream_ptr_(std::move(stream_ptr))
822 , socket_(stream_ptr_->next_layer().socket())
823 , stream_(*stream_ptr_)
824 , strand_(boost::asio::make_strand(socket_.get_executor()))
825 , timer_(waitable_timer{socket_.get_executor()})
826 , remote_address_(slot->remote_endpoint())
827 , overlay_(overlay)
828 , inbound_(false)
829 , protocol_(protocol)
830 , tracking_(Tracking::unknown)
831 , trackingTime_(clock_type::now())
832 , publicKey_(publicKey)
833 , lastPingTime_(clock_type::now())
834 , creationTime_(clock_type::now())
835 , squelch_(app_.getJournal("Squelch"))
836 , usage_(usage)
837 , fee_{Resource::feeTrivialPeer}
838 , slot_(std::move(slot))
839 , response_(std::move(response))
840 , headers_(response_)
841 , compressionEnabled_(
842 peerFeatureEnabled(headers_, FEATURE_COMPR, "lz4", app_.config().COMPRESSION)
843 ? Compressed::On
844 : Compressed::Off)
845 , txReduceRelayEnabled_(
846 peerFeatureEnabled(headers_, FEATURE_TXRR, app_.config().TX_REDUCE_RELAY_ENABLE))
847 , ledgerReplayEnabled_(
848 peerFeatureEnabled(headers_, FEATURE_LEDGER_REPLAY, app_.config().LEDGER_REPLAY))
849 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
850{
851 read_buffer_.commit(
852 boost::asio::buffer_copy(read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
853 JLOG(journal_.info()) << "compression enabled " << (compressionEnabled_ == Compressed::On)
854 << " vp reduce-relay base squelch enabled "
856 headers_,
859 << " tx reduce-relay enabled " << txReduceRelayEnabled_ << " on "
860 << remote_address_ << " " << id_;
861}
862
863template <class FwdIt, class>
864void
865PeerImp::sendEndpoints(FwdIt first, FwdIt last)
866{
867 protocol::TMEndpoints tm;
868
869 while (first != last)
870 {
871 auto& tme2(*tm.add_endpoints_v2());
872 tme2.set_endpoint(first->address.to_string());
873 tme2.set_hops(first->hops);
874 first++;
875 }
876 tm.set_version(2);
877
878 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
879}
880
881} // 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:307
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:233
std::shared_mutex mutex_
Definition PeerImp.h:270
std::uint64_t rollingAvgBytes_
Definition PeerImp.h:275
clock_type::time_point intervalStart_
Definition PeerImp.h:272
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition PeerImp.h:271
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:3544
std::uint64_t total_bytes() const
Definition PeerImp.cpp:3551
std::uint64_t accumBytes_
Definition PeerImp.h:274
void add_message(std::uint64_t bytes)
Definition PeerImp.cpp:3520
std::uint64_t totalBytes_
Definition PeerImp.h:273
This class manages established peer-to-peer connections, handles message exchange,...
Definition PeerImp.h:95
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition PeerImp.cpp:2065
std::optional< std::chrono::milliseconds > latency_
Definition PeerImp.h:156
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition PeerImp.cpp:310
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition PeerImp.cpp:371
std::unique_ptr< LoadEvent > load_event_
Definition PeerImp.h:232
beast::Journal const p_journal_
Definition PeerImp.h:118
boost::asio::ip::tcp::endpoint endpoint_type
Definition PeerImp.h:107
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition PeerImp.cpp:1160
ProtocolVersion protocol_
Definition PeerImp.h:137
bool txReduceRelayEnabled_
Definition PeerImp.h:244
void checkTransaction(HashRouterFlags flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
Definition PeerImp.cpp:2875
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition PeerImp.h:325
void close()
Forcibly closes the underlying socket connection.
Definition PeerImp.cpp:658
boost::beast::tcp_stream middle_type
Definition PeerImp.h:104
bool readPending_
Definition PeerImp.h:226
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
Called from onMessage(TMTransaction(s)).
Definition PeerImp.cpp:1352
http_request_type request_
Definition PeerImp.h:214
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition PeerImp.cpp:329
beast::WrappedSink sink_
Definition PeerImp.h:115
std::string name() const
Definition PeerImp.cpp:880
bool txReduceRelayEnabled() const override
Definition PeerImp.h:486
std::shared_ptr< PeerFinder::Slot > const slot_
Definition PeerImp.h:212
boost::asio::ip::tcp::socket socket_type
Definition PeerImp.h:103
boost::beast::http::fields const & headers_
Definition PeerImp.h:216
Compressed compressionEnabled_
Definition PeerImp.h:237
void onTimer(error_code const &ec)
Handles the expiration of the peer activity timer.
Definition PeerImp.cpp:710
uint256 const & getClosedLedgerHash() const override
Definition PeerImp.h:452
boost::system::error_code error_code
Definition PeerImp.h:102
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition PeerImp.cpp:2778
PeerImp & operator=(PeerImp const &)=delete
void tryAsyncShutdown()
Attempts to perform a graceful SSL shutdown if conditions are met.
Definition PeerImp.cpp:597
LedgerIndex minLedger_
Definition PeerImp.h:148
std::string prefix_
Definition PeerImp.h:114
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition PeerImp.h:865
id_t const id_
Definition PeerImp.h:112
Metrics sent
Definition PeerImp.h:280
std::string const & fingerprint() const override
Definition PeerImp.h:667
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:342
bool ledgerReplayEnabled_
Definition PeerImp.h:246
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition PeerImp.cpp:289
uint256 closedLedgerHash_
Definition PeerImp.h:150
reduce_relay::Squelch< UptimeClock > squelch_
Definition PeerImp.h:161
stream_type & stream_
Definition PeerImp.h:121
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:3057
void cycleStatus() override
Definition PeerImp.cpp:540
std::shared_mutex nameMutex_
Definition PeerImp.h:144
socket_type & socket_
Definition PeerImp.h:120
beast::IP::Endpoint const remote_address_
Definition PeerImp.h:129
int large_sendq_
Definition PeerImp.h:231
std::string domain() const
Definition PeerImp.cpp:887
std::atomic< Tracking > tracking_
Definition PeerImp.h:139
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:524
clock_type::duration uptime() const
Definition PeerImp.h:417
boost::asio::ip::address address_type
Definition PeerImp.h:106
LedgerIndex maxLedger_
Definition PeerImp.h:149
Application & app_
Definition PeerImp.h:111
PublicKey const publicKey_
Definition PeerImp.h:142
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:1113
Json::Value json() override
Definition PeerImp.cpp:379
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition PeerImp.cpp:365
Metrics recv
Definition PeerImp.h:281
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition PeerImp.cpp:3009
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition PeerImp.cpp:1041
virtual void run()
Definition PeerImp.cpp:134
OverlayImpl & overlay_
Definition PeerImp.h:133
std::queue< std::shared_ptr< Message > > send_queue_
Definition PeerImp.h:217
virtual ~PeerImp()
Definition PeerImp.cpp:111
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition PeerImp.cpp:3148
Peer::id_t id() const override
Definition PeerImp.h:384
static std::string makePrefix(std::string const &fingerprint)
Definition PeerImp.cpp:702
beast::Journal const & pJournal() const
Definition PeerImp.h:319
ChargeWithContext fee_
Definition PeerImp.h:211
void onShutdown(error_code ec)
Handles the completion of the asynchronous SSL shutdown.
Definition PeerImp.cpp:634
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:2662
beast::IP::Endpoint getRemoteAddress() const override
Definition PeerImp.h:371
void onMessageUnknown(std::uint16_t type)
Definition PeerImp.cpp:1107
protocol::TMStatusChange last_status_
Definition PeerImp.h:209
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition PeerImp.cpp:942
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:3301
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition PeerImp.h:98
std::unique_ptr< stream_type > stream_ptr_
Definition PeerImp.h:119
clock_type::time_point const creationTime_
Definition PeerImp.h:159
struct xrpl::PeerImp::@22 metrics_
beast::WrappedSink p_sink_
Definition PeerImp.h:116
boost::beast::multi_buffer read_buffer_
Definition PeerImp.h:213
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition PeerImp.h:247
void send(std::shared_ptr< Message > const &m) override
Definition PeerImp.cpp:219
hash_set< uint256 > txQueue_
Definition PeerImp.h:242
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Definition PeerImp.cpp:2791
bool supportsFeature(ProtocolFeature f) const override
Definition PeerImp.cpp:493
void doProtocolStart()
Definition PeerImp.cpp:897
void shutdown()
Initiates the peer disconnection sequence.
Definition PeerImp.cpp:619
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:3185
bool const inbound_
Definition PeerImp.h:134
boost::asio::strand< boost::asio::executor > strand_
Definition PeerImp.h:122
waitable_timer timer_
Definition PeerImp.h:125
clock_type::time_point lastPingTime_
Definition PeerImp.h:158
boost::circular_buffer< uint256 > recentLedgers_
Definition PeerImp.h:153
int getScore(bool haveItem) const override
Definition PeerImp.cpp:3471
std::string name_
Definition PeerImp.h:143
bool hasTxSet(uint256 const &hash) const override
Definition PeerImp.cpp:533
bool writePending_
Definition PeerImp.h:229
http_response_type response_
Definition PeerImp.h:215
boost::circular_buffer< uint256 > recentTxSets_
Definition PeerImp.h:154
clock_type::time_point trackingTime_
Definition PeerImp.h:140
beast::Journal const journal_
Definition PeerImp.h:117
std::string fingerprint_
Definition PeerImp.h:113
bool isHighLatency() const override
Definition PeerImp.cpp:3513
void cancelTimer() noexcept
Cancels any pending wait on the peer activity timer.
Definition PeerImp.cpp:782
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition PeerImp.cpp:550
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition PeerImp.cpp:3269
uint256 previousLedgerHash_
Definition PeerImp.h:151
Resource::Consumer usage_
Definition PeerImp.h:210
bool shutdownStarted_
Definition PeerImp.h:223
std::optional< std::uint32_t > lastPingSeq_
Definition PeerImp.h:157
boost::beast::ssl_stream< middle_type > stream_type
Definition PeerImp.h:105
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition PeerImp.cpp:356
void stop() override
Definition PeerImp.cpp:196
void setTimer(std::chrono::seconds interval)
Sets and starts the peer timer.
Definition PeerImp.cpp:682
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
Definition PeerImp.cpp:2130
bool shutdown_
Definition PeerImp.h:220
std::string const & prefix() const
Definition PeerImp.h:673
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
Definition PeerImp.cpp:2824
void doAccept()
Definition PeerImp.cpp:796
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition PeerImp.h:235
void fail(std::string const &name, error_code ec)
Handles a failure associated with a specific error code.
Definition PeerImp.cpp:559
std::mutex recentLock_
Definition PeerImp.h:208
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition PeerImp.cpp:510
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition PeerImp.h:108
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition PeerImp.cpp:1153
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:602
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:171
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:242
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:196