rippled
Loading...
Searching...
No Matches
PeerImp.h
1#ifndef XRPL_OVERLAY_PEERIMP_H_INCLUDED
2#define XRPL_OVERLAY_PEERIMP_H_INCLUDED
3
4#include <xrpld/app/consensus/RCLCxPeerPos.h>
5#include <xrpld/app/ledger/detail/LedgerReplayMsgHandler.h>
6#include <xrpld/app/misc/HashRouter.h>
7#include <xrpld/overlay/Squelch.h>
8#include <xrpld/overlay/detail/OverlayImpl.h>
9#include <xrpld/overlay/detail/ProtocolVersion.h>
10#include <xrpld/peerfinder/PeerfinderManager.h>
11
12#include <xrpl/basics/Log.h>
13#include <xrpl/basics/UnorderedContainers.h>
14#include <xrpl/beast/utility/WrappedSink.h>
15#include <xrpl/protocol/Protocol.h>
16#include <xrpl/protocol/STTx.h>
17#include <xrpl/protocol/STValidation.h>
18#include <xrpl/resource/Fees.h>
19
20#include <boost/circular_buffer.hpp>
21#include <boost/endian/conversion.hpp>
22#include <boost/thread/shared_mutex.hpp>
23
24#include <atomic>
25#include <cstdint>
26#include <optional>
27#include <queue>
28
29namespace ripple {
30
31struct ValidatorBlobInfo;
32class SHAMap;
33
96class PeerImp : public Peer,
97 public std::enable_shared_from_this<PeerImp>,
99{
100public:
103
104private:
106 using error_code = boost::system::error_code;
107 using socket_type = boost::asio::ip::tcp::socket;
108 using middle_type = boost::beast::tcp_stream;
109 using stream_type = boost::beast::ssl_stream<middle_type>;
110 using address_type = boost::asio::ip::address;
111 using endpoint_type = boost::asio::ip::tcp::endpoint;
113 boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
115
117 id_t const id_;
127 boost::asio::strand<boost::asio::executor> strand_;
128
129 // Multi-purpose timer for peer activity monitoring and shutdown safety
131
132 // Updated at each stage of the connection process to reflect
133 // the current conditions as closely as possible.
135
136 // These are up here to prevent warnings about order of initializations
137 //
139 bool const inbound_;
140
141 // Protocol version to use for this link
143
145 clock_type::time_point trackingTime_;
146 // Node public key of peer.
150
151 // The indices of the smallest and largest ledgers this peer has available
152 //
157
158 boost::circular_buffer<uint256> recentLedgers_{128};
159 boost::circular_buffer<uint256> recentTxSets_{128};
160
163 clock_type::time_point lastPingTime_;
164 clock_type::time_point const creationTime_;
165
167
168 // Notes on thread locking:
169 //
170 // During an audit it was noted that some member variables that looked
171 // like they need thread protection were not receiving it. And, indeed,
172 // that was correct. But the multi-phase initialization of PeerImp
173 // makes such an audit difficult. A further audit suggests that the
174 // locking is now protecting variables that don't need it. We're
175 // leaving that locking in place (for now) as a form of future proofing.
176 //
177 // Here are the variables that appear to need locking currently:
178 //
179 // o closedLedgerHash_
180 // o previousLedgerHash_
181 // o minLedger_
182 // o maxLedger_
183 // o recentLedgers_
184 // o recentTxSets_
185 // o trackingTime_
186 // o latency_
187 //
188 // The following variables are being protected preemptively:
189 //
190 // o name_
191 // o last_status_
192 //
193 // June 2019
194
196 {
199
200 void
202 {
203 XRPL_ASSERT(
204 f >= fee,
205 "ripple::PeerImp::ChargeWithContext::update : fee increases");
206 fee = f;
207 if (!context.empty())
208 {
209 context += " ";
210 }
211 context += add;
212 }
213 };
214
216 protocol::TMStatusChange last_status_;
220 boost::beast::multi_buffer read_buffer_;
223 boost::beast::http::fields const& headers_;
225
226 // Primary shutdown flag set when shutdown is requested
227 bool shutdown_ = false;
228
229 // SSL shutdown coordination flag
230 bool shutdownStarted_ = false;
231
232 // Indicates a read operation is currently pending
233 bool readPending_ = false;
234
235 // Indicates a write operation is currently pending
236 bool writePending_ = false;
237
240 // The highest sequence of each PublisherList that has
241 // been sent to or received from this peer.
243
245
246 // Queue of transactions' hashes that have not been
247 // relayed. The hashes are sent once a second to a peer
248 // and the peer requests missing transactions from the node.
250 // true if tx reduce-relay feature is enabled on the peer.
252
255
256 friend class OverlayImpl;
257
259 {
260 public:
261 Metrics() = default;
262 Metrics(Metrics const&) = delete;
263 Metrics&
264 operator=(Metrics const&) = delete;
265 Metrics(Metrics&&) = delete;
266 Metrics&
267 operator=(Metrics&&) = delete;
268
269 void
272 average_bytes() const;
274 total_bytes() const;
275
276 private:
278 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
279 clock_type::time_point intervalStart_{clock_type::now()};
283 };
284
285 struct
286 {
290
291public:
292 PeerImp(PeerImp const&) = delete;
293 PeerImp&
294 operator=(PeerImp const&) = delete;
295
297 PeerImp(
298 Application& app,
299 id_t id,
301 http_request_type&& request,
302 PublicKey const& publicKey,
304 Resource::Consumer consumer,
305 std::unique_ptr<stream_type>&& stream_ptr,
306 OverlayImpl& overlay);
307
309 // VFALCO legacyPublicKey should be implied by the Slot
310 template <class Buffers>
311 PeerImp(
312 Application& app,
313 std::unique_ptr<stream_type>&& stream_ptr,
314 Buffers const& buffers,
316 http_response_type&& response,
317 Resource::Consumer usage,
318 PublicKey const& publicKey,
320 id_t id,
321 OverlayImpl& overlay);
322
323 virtual ~PeerImp();
324
325 beast::Journal const&
326 pjournal() const
327 {
328 return p_journal_;
329 }
330
333 {
334 return slot_;
335 }
336
337 // Work-around for calling shared_from_this in constructors
338 virtual void
339 run();
340
341 // Called when Overlay gets a stop request.
342 void
343 stop() override;
344
345 //
346 // Network
347 //
348
349 void
350 send(std::shared_ptr<Message> const& m) override;
351
353 void
354 sendTxQueue() override;
355
359 void
360 addTxQueue(uint256 const& hash) override;
361
365 void
366 removeTxQueue(uint256 const& hash) override;
367
369 template <
370 class FwdIt,
371 class = typename std::enable_if_t<std::is_same<
373 PeerFinder::Endpoint>::value>>
374 void
375 sendEndpoints(FwdIt first, FwdIt last);
376
378 getRemoteAddress() const override
379 {
380 return remote_address_;
381 }
382
383 void
384 charge(Resource::Charge const& fee, std::string const& context) override;
385
386 //
387 // Identity
388 //
389
391 id() const override
392 {
393 return id_;
394 }
395
397 bool
398 crawl() const;
399
400 bool
401 cluster() const override;
402
406 void
407 checkTracking(std::uint32_t validationSeq);
408
409 void
411
412 PublicKey const&
413 getNodePublic() const override
414 {
415 return publicKey_;
416 }
417
420 getVersion() const;
421
422 // Return the connection elapsed time.
423 clock_type::duration
424 uptime() const
425 {
427 }
428
430 json() override;
431
432 bool
433 supportsFeature(ProtocolFeature f) const override;
434
436 publisherListSequence(PublicKey const& pubKey) const override
437 {
439
440 auto iter = publisherListSequences_.find(pubKey);
441 if (iter != publisherListSequences_.end())
442 return iter->second;
443 return {};
444 }
445
446 void
448 override
449 {
451
452 publisherListSequences_[pubKey] = seq;
453 }
454
455 //
456 // Ledger
457 //
458
459 uint256 const&
460 getClosedLedgerHash() const override
461 {
462 return closedLedgerHash_;
463 }
464
465 bool
466 hasLedger(uint256 const& hash, std::uint32_t seq) const override;
467
468 void
469 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
470
471 bool
472 hasTxSet(uint256 const& hash) const override;
473
474 void
475 cycleStatus() override;
476
477 bool
478 hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
479
480 // Called to determine our priority for querying
481 int
482 getScore(bool haveItem) const override;
483
484 bool
485 isHighLatency() const override;
486
487 bool
488 compressionEnabled() const override
489 {
490 return compressionEnabled_ == Compressed::On;
491 }
492
493 bool
494 txReduceRelayEnabled() const override
495 {
497 }
498
499private:
514 void
515 fail(std::string const& name, error_code ec);
516
530 void
531 fail(std::string const& reason);
532
542 void
543 shutdown();
544
554 void
556
569 void
571
583 void
584 close();
585
595 void
597
608 void
609 onTimer(error_code const& ec);
610
617 void
618 cancelTimer() noexcept;
619
620 static std::string
621 makePrefix(std::string const& fingerprint);
622
623 void
624 doAccept();
625
626 std::string
627 name() const;
628
629 std::string
630 domain() const;
631
632 //
633 // protocol message loop
634 //
635
636 // Starts the protocol message loop
637 void
639
640 // Called when protocol message bytes are received
641 void
642 onReadMessage(error_code ec, std::size_t bytes_transferred);
643
644 // Called when protocol messages bytes are sent
645 void
646 onWriteMessage(error_code ec, std::size_t bytes_transferred);
647
660 void
662 std::shared_ptr<protocol::TMTransaction> const& m,
663 bool eraseTxQueue,
664 bool batch);
665
671 void
673 std::shared_ptr<protocol::TMHaveTransactions> const& m);
674
675 std::string const&
676 fingerprint() const override
677 {
678 return fingerprint_;
679 }
680
681 std::string const&
682 prefix() const
683 {
684 return prefix_;
685 }
686
687public:
688 //--------------------------------------------------------------------------
689 //
690 // ProtocolStream
691 //
692 //--------------------------------------------------------------------------
693
694 void
696
697 void
699 std::uint16_t type,
701 std::size_t size,
702 std::size_t uncompressed_size,
703 bool isCompressed);
704
705 void
707 std::uint16_t type,
709
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 void
740 void
742 void
744 void
746 void
748 void
750 void
752
753private:
754 //--------------------------------------------------------------------------
755 // lockedRecentLock is passed as a reminder to callers that recentLock_
756 // must be locked.
757 void
758 addLedger(
759 uint256 const& hash,
760 std::lock_guard<std::mutex> const& lockedRecentLock);
761
762 void
764
765 void
767 std::string const& messageType,
768 std::string const& manifest,
769 std::uint32_t version,
770 std::vector<ValidatorBlobInfo> const& blobs);
771
776 void
778
779 void
781 HashRouterFlags flags,
782 bool checkSignature,
784 bool batch);
785
786 void
788 bool isTrusted,
790 RCLCxPeerPos peerPos);
791
792 void
795 uint256 const& key,
797
798 void
800 std::shared_ptr<Ledger const> const& ledger,
801 protocol::TMLedgerData& ledgerData);
802
805
808
809 void
811};
812
813//------------------------------------------------------------------------------
814
815template <class Buffers>
817 Application& app,
818 std::unique_ptr<stream_type>&& stream_ptr,
819 Buffers const& buffers,
821 http_response_type&& response,
822 Resource::Consumer usage,
823 PublicKey const& publicKey,
825 id_t id,
826 OverlayImpl& overlay)
827 : Child(overlay)
828 , app_(app)
829 , id_(id)
830 , fingerprint_(
831 getFingerprint(slot->remote_endpoint(), publicKey, to_string(id_)))
832 , prefix_(makePrefix(fingerprint_))
833 , sink_(app_.journal("Peer"), prefix_)
834 , p_sink_(app_.journal("Protocol"), prefix_)
835 , journal_(sink_)
836 , p_journal_(p_sink_)
837 , stream_ptr_(std::move(stream_ptr))
838 , socket_(stream_ptr_->next_layer().socket())
839 , stream_(*stream_ptr_)
840 , strand_(boost::asio::make_strand(socket_.get_executor()))
841 , timer_(waitable_timer{socket_.get_executor()})
842 , remote_address_(slot->remote_endpoint())
843 , overlay_(overlay)
844 , inbound_(false)
845 , protocol_(protocol)
846 , tracking_(Tracking::unknown)
847 , trackingTime_(clock_type::now())
848 , publicKey_(publicKey)
849 , lastPingTime_(clock_type::now())
850 , creationTime_(clock_type::now())
851 , squelch_(app_.journal("Squelch"))
852 , usage_(usage)
853 , fee_{Resource::feeTrivialPeer}
854 , slot_(std::move(slot))
855 , response_(std::move(response))
856 , headers_(response_)
857 , compressionEnabled_(
859 headers_,
861 "lz4",
862 app_.config().COMPRESSION)
863 ? Compressed::On
864 : Compressed::Off)
865 , txReduceRelayEnabled_(peerFeatureEnabled(
866 headers_,
868 app_.config().TX_REDUCE_RELAY_ENABLE))
869 , ledgerReplayEnabled_(peerFeatureEnabled(
870 headers_,
872 app_.config().LEDGER_REPLAY))
873 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
874{
875 read_buffer_.commit(boost::asio::buffer_copy(
876 read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
877 JLOG(journal_.info())
878 << "compression enabled " << (compressionEnabled_ == Compressed::On)
879 << " vp reduce-relay base squelch enabled "
881 headers_,
884 << " tx reduce-relay enabled " << txReduceRelayEnabled_ << " on "
885 << remote_address_ << " " << id_;
886}
887
888template <class FwdIt, class>
889void
890PeerImp::sendEndpoints(FwdIt first, FwdIt last)
891{
892 protocol::TMEndpoints tm;
893
894 while (first != last)
895 {
896 auto& tme2(*tm.add_endpoints_v2());
897 tme2.set_endpoint(first->address.to_string());
898 tme2.set_hops(first->hops);
899 first++;
900 }
901 tm.set_version(2);
902
903 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
904}
905
906} // namespace ripple
907
908#endif
Represents a JSON value.
Definition json_value.h:130
A version-independent IP address and port combination.
Definition IPEndpoint.h:19
A generic endpoint for log messages.
Definition Journal.h:41
Stream info() const
Definition Journal.h:315
Wraps a Journal::Sink to prefix its output with a string.
Definition WrappedSink.h:15
virtual Config & config()=0
bool VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE
Definition Config.h:229
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition PeerImp.h:278
std::uint64_t accumBytes_
Definition PeerImp.h:281
Metrics & operator=(Metrics const &)=delete
Metrics(Metrics &&)=delete
std::uint64_t total_bytes() const
Definition PeerImp.cpp:3622
std::uint64_t totalBytes_
Definition PeerImp.h:280
Metrics & operator=(Metrics &&)=delete
std::uint64_t average_bytes() const
Definition PeerImp.cpp:3615
void add_message(std::uint64_t bytes)
Definition PeerImp.cpp:3589
Metrics(Metrics const &)=delete
std::shared_mutex mutex_
Definition PeerImp.h:277
std::uint64_t rollingAvgBytes_
Definition PeerImp.h:282
clock_type::time_point intervalStart_
Definition PeerImp.h:279
This class manages established peer-to-peer connections, handles message exchange,...
Definition PeerImp.h:99
std::string const & prefix() const
Definition PeerImp.h:682
std::queue< std::shared_ptr< Message > > send_queue_
Definition PeerImp.h:224
boost::beast::ssl_stream< middle_type > stream_type
Definition PeerImp.h:109
PeerImp & operator=(PeerImp const &)=delete
std::unique_ptr< LoadEvent > load_event_
Definition PeerImp.h:239
boost::beast::http::fields const & headers_
Definition PeerImp.h:223
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
Definition PeerImp.cpp:2114
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition PeerImp.cpp:1138
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition PeerImp.cpp:509
Metrics sent
Definition PeerImp.h:287
clock_type::duration uptime() const
Definition PeerImp.h:424
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition PeerImp.cpp:325
protocol::TMStatusChange last_status_
Definition PeerImp.h:216
std::string name_
Definition PeerImp.h:148
boost::circular_buffer< uint256 > recentTxSets_
Definition PeerImp.h:159
std::unique_ptr< stream_type > stream_ptr_
Definition PeerImp.h:124
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition PeerImp.cpp:1147
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition PeerImp.h:102
Compressed compressionEnabled_
Definition PeerImp.h:244
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition PeerImp.h:436
uint256 closedLedgerHash_
Definition PeerImp.h:155
std::string domain() const
Definition PeerImp.cpp:880
std::optional< std::uint32_t > lastPingSeq_
Definition PeerImp.h:162
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition PeerImp.h:332
http_response_type response_
Definition PeerImp.h:222
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition PeerImp.h:890
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition PeerImp.cpp:3194
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Definition PeerImp.cpp:2827
std::string const & fingerprint() const override
Definition PeerImp.h:676
boost::asio::ip::tcp::endpoint endpoint_type
Definition PeerImp.h:111
beast::Journal const journal_
Definition PeerImp.h:122
virtual void run()
Definition PeerImp.cpp:144
boost::asio::ip::address address_type
Definition PeerImp.h:110
void tryAsyncShutdown()
Attempts to perform a graceful SSL shutdown if conditions are met.
Definition PeerImp.cpp:600
LedgerIndex maxLedger_
Definition PeerImp.h:154
beast::Journal const p_journal_
Definition PeerImp.h:123
bool const inbound_
Definition PeerImp.h:139
PeerImp(PeerImp const &)=delete
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition PeerImp.cpp:3365
Application & app_
Definition PeerImp.h:116
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition PeerImp.cpp:3330
void stop() override
Definition PeerImp.cpp:202
void shutdown()
Initiates the peer disconnection sequence.
Definition PeerImp.cpp:624
void checkTransaction(HashRouterFlags flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
Definition PeerImp.cpp:2916
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition PeerImp.cpp:551
bool hasTxSet(uint256 const &hash) const override
Definition PeerImp.cpp:533
clock_type::time_point lastPingTime_
Definition PeerImp.h:163
void onMessageUnknown(std::uint16_t type)
Definition PeerImp.cpp:1089
std::shared_ptr< PeerFinder::Slot > const slot_
Definition PeerImp.h:219
std::shared_mutex nameMutex_
Definition PeerImp.h:149
boost::circular_buffer< uint256 > recentLedgers_
Definition PeerImp.h:158
std::string fingerprint_
Definition PeerImp.h:118
id_t const id_
Definition PeerImp.h:117
std::optional< std::chrono::milliseconds > latency_
Definition PeerImp.h:161
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
Called from onMessage(TMTransaction(s)).
Definition PeerImp.cpp:1339
beast::IP::Endpoint const remote_address_
Definition PeerImp.h:134
boost::asio::ip::tcp::socket socket_type
Definition PeerImp.h:107
Json::Value json() override
Definition PeerImp.cpp:374
PublicKey const publicKey_
Definition PeerImp.h:147
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition PeerImp.cpp:2811
void close()
Forcibly closes the underlying socket connection.
Definition PeerImp.cpp:667
hash_set< uint256 > txQueue_
Definition PeerImp.h:249
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition PeerImp.cpp:3234
std::mutex recentLock_
Definition PeerImp.h:215
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:1095
bool txReduceRelayEnabled_
Definition PeerImp.h:251
beast::IP::Endpoint getRemoteAddress() const override
Definition PeerImp.h:378
Metrics recv
Definition PeerImp.h:288
void fail(std::string const &name, error_code ec)
Handles a failure associated with a specific error code.
Definition PeerImp.cpp:561
clock_type::time_point trackingTime_
Definition PeerImp.h:145
void cancelTimer() noexcept
Cancels any pending wait on the peer activity timer.
Definition PeerImp.cpp:789
bool shutdownStarted_
Definition PeerImp.h:230
socket_type & socket_
Definition PeerImp.h:125
ProtocolVersion protocol_
Definition PeerImp.h:142
clock_type::time_point const creationTime_
Definition PeerImp.h:164
reduce_relay::Squelch< UptimeClock > squelch_
Definition PeerImp.h:166
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition PeerImp.h:242
bool writePending_
Definition PeerImp.h:236
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition PeerImp.cpp:366
struct ripple::PeerImp::@22 metrics_
uint256 previousLedgerHash_
Definition PeerImp.h:156
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:337
boost::beast::tcp_stream middle_type
Definition PeerImp.h:108
int getScore(bool haveItem) const override
Definition PeerImp.cpp:3544
void onTimer(error_code const &ec)
Handles the expiration of the peer activity timer.
Definition PeerImp.cpp:722
void send(std::shared_ptr< Message > const &m) override
Definition PeerImp.cpp:222
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
Definition PeerImp.cpp:2861
std::string name() const
Definition PeerImp.cpp:873
boost::system::error_code error_code
Definition PeerImp.h:106
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition PeerImp.cpp:932
bool ledgerReplayEnabled_
Definition PeerImp.h:253
beast::WrappedSink p_sink_
Definition PeerImp.h:121
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition PeerImp.h:113
PublicKey const & getNodePublic() const override
Definition PeerImp.h:413
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition PeerImp.cpp:351
waitable_timer timer_
Definition PeerImp.h:130
beast::Journal const & pjournal() const
Definition PeerImp.h:326
void setTimer(std::chrono::seconds interval)
Sets and starts the peer timer.
Definition PeerImp.cpp:693
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition PeerImp.cpp:289
bool compressionEnabled() const override
Definition PeerImp.h:488
bool txReduceRelayEnabled() const override
Definition PeerImp.h:494
bool supportsFeature(ProtocolFeature f) const override
Definition PeerImp.cpp:492
uint256 const & getClosedLedgerHash() const override
Definition PeerImp.h:460
beast::WrappedSink sink_
Definition PeerImp.h:120
ChargeWithContext fee_
Definition PeerImp.h:218
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition PeerImp.cpp:1023
http_request_type request_
Definition PeerImp.h:221
OverlayImpl & overlay_
Definition PeerImp.h:138
LedgerIndex minLedger_
Definition PeerImp.h:153
virtual ~PeerImp()
Definition PeerImp.cpp:121
Peer::id_t id() const override
Definition PeerImp.h:391
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition PeerImp.h:254
std::string prefix_
Definition PeerImp.h:119
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:2691
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition PeerImp.cpp:308
stream_type & stream_
Definition PeerImp.h:126
static std::string makePrefix(std::string const &fingerprint)
Definition PeerImp.cpp:714
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition PeerImp.cpp:360
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition PeerImp.cpp:3054
bool isHighLatency() const override
Definition PeerImp.cpp:3582
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition PeerImp.cpp:2047
void onShutdown(error_code ec)
Handles the completion of the asynchronous SSL shutdown.
Definition PeerImp.cpp:641
boost::asio::strand< boost::asio::executor > strand_
Definition PeerImp.h:127
void cycleStatus() override
Definition PeerImp.cpp:541
boost::beast::multi_buffer read_buffer_
Definition PeerImp.h:220
Resource::Consumer usage_
Definition PeerImp.h:217
void checkValidation(std::shared_ptr< STValidation > const &val, uint256 const &key, std::shared_ptr< protocol::TMValidation > const &packet)
Definition PeerImp.cpp:3097
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition PeerImp.h:447
bool readPending_
Definition PeerImp.h:233
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition PeerImp.cpp:524
void doProtocolStart()
Definition PeerImp.cpp:890
std::atomic< Tracking > tracking_
Definition PeerImp.h:144
Represents a peer connection in the overlay.
A public key.
Definition PublicKey.h:43
A peer's signed, proposed position for use in RCLConsensus.
A consumption charge.
Definition Charge.h:11
An endpoint that consumes resources.
Definition Consumer.h:17
Maintains squelching of relaying messages from validators.
Definition Squelch.h:20
T empty(T... args)
Charge const feeTrivialPeer
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
Definition Handoff.h:17
static constexpr char FEATURE_COMPR[]
Definition Handshake.h:122
static constexpr char FEATURE_LEDGER_REPLAY[]
Definition Handshake.h:128
HashRouterFlags
Definition HashRouter.h:15
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition Handoff.h:14
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:250
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:179
static constexpr char FEATURE_TXRR[]
Definition Handshake.h:126
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:611
@ manifest
Manifest.
static constexpr char FEATURE_VPRR[]
Definition Handshake.h:124
STL namespace.
Describes a connectible peer address along with some metadata.
void update(Resource::Charge f, std::string const &add)
Definition PeerImp.h:201