rippled
Loading...
Searching...
No Matches
PeerImp.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_OVERLAY_PEERIMP_H_INCLUDED
21#define RIPPLE_OVERLAY_PEERIMP_H_INCLUDED
22
23#include <xrpld/app/consensus/RCLCxPeerPos.h>
24#include <xrpld/app/ledger/detail/LedgerReplayMsgHandler.h>
25#include <xrpld/app/misc/HashRouter.h>
26#include <xrpld/overlay/Squelch.h>
27#include <xrpld/overlay/detail/OverlayImpl.h>
28#include <xrpld/overlay/detail/ProtocolVersion.h>
29#include <xrpld/peerfinder/PeerfinderManager.h>
30
31#include <xrpl/basics/Log.h>
32#include <xrpl/basics/UnorderedContainers.h>
33#include <xrpl/beast/utility/WrappedSink.h>
34#include <xrpl/protocol/Protocol.h>
35#include <xrpl/protocol/STTx.h>
36#include <xrpl/protocol/STValidation.h>
37#include <xrpl/resource/Fees.h>
38
39#include <boost/circular_buffer.hpp>
40#include <boost/endian/conversion.hpp>
41#include <boost/thread/shared_mutex.hpp>
42
43#include <atomic>
44#include <cstdint>
45#include <optional>
46#include <queue>
47
48namespace ripple {
49
50struct ValidatorBlobInfo;
51class SHAMap;
52
115class PeerImp : public Peer,
116 public std::enable_shared_from_this<PeerImp>,
117 public OverlayImpl::Child
118{
119public:
122
123private:
125 using error_code = boost::system::error_code;
126 using socket_type = boost::asio::ip::tcp::socket;
127 using middle_type = boost::beast::tcp_stream;
128 using stream_type = boost::beast::ssl_stream<middle_type>;
129 using address_type = boost::asio::ip::address;
130 using endpoint_type = boost::asio::ip::tcp::endpoint;
132 boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
134
136 id_t const id_;
144 boost::asio::strand<boost::asio::executor> strand_;
145
146 // Multi-purpose timer for peer activity monitoring and shutdown safety
148
149 // Updated at each stage of the connection process to reflect
150 // the current conditions as closely as possible.
152
153 // These are up here to prevent warnings about order of initializations
154 //
156 bool const inbound_;
157
158 // Protocol version to use for this link
160
162 clock_type::time_point trackingTime_;
163 // Node public key of peer.
167
168 // The indices of the smallest and largest ledgers this peer has available
169 //
174
175 boost::circular_buffer<uint256> recentLedgers_{128};
176 boost::circular_buffer<uint256> recentTxSets_{128};
177
180 clock_type::time_point lastPingTime_;
181 clock_type::time_point const creationTime_;
182
184
185 // Notes on thread locking:
186 //
187 // During an audit it was noted that some member variables that looked
188 // like they need thread protection were not receiving it. And, indeed,
189 // that was correct. But the multi-phase initialization of PeerImp
190 // makes such an audit difficult. A further audit suggests that the
191 // locking is now protecting variables that don't need it. We're
192 // leaving that locking in place (for now) as a form of future proofing.
193 //
194 // Here are the variables that appear to need locking currently:
195 //
196 // o closedLedgerHash_
197 // o previousLedgerHash_
198 // o minLedger_
199 // o maxLedger_
200 // o recentLedgers_
201 // o recentTxSets_
202 // o trackingTime_
203 // o latency_
204 //
205 // The following variables are being protected preemptively:
206 //
207 // o name_
208 // o last_status_
209 //
210 // June 2019
211
213 {
216
217 void
219 {
220 XRPL_ASSERT(
221 f >= fee,
222 "ripple::PeerImp::ChargeWithContext::update : fee increases");
223 fee = f;
224 if (!context.empty())
225 {
226 context += " ";
227 }
228 context += add;
229 }
230 };
231
233 protocol::TMStatusChange last_status_;
237 boost::beast::multi_buffer read_buffer_;
240 boost::beast::http::fields const& headers_;
242
243 // Primary shutdown flag set when shutdown is requested
244 bool shutdown_ = false;
245
246 // SSL shutdown coordination flag
247 bool shutdownStarted_ = false;
248
249 // Indicates a read operation is currently pending
250 bool readPending_ = false;
251
252 // Indicates a write operation is currently pending
253 bool writePending_ = false;
254
257 // The highest sequence of each PublisherList that has
258 // been sent to or received from this peer.
260
262
263 // Queue of transactions' hashes that have not been
264 // relayed. The hashes are sent once a second to a peer
265 // and the peer requests missing transactions from the node.
267 // true if tx reduce-relay feature is enabled on the peer.
269
272
273 friend class OverlayImpl;
274
276 {
277 public:
278 Metrics() = default;
279 Metrics(Metrics const&) = delete;
280 Metrics&
281 operator=(Metrics const&) = delete;
282 Metrics(Metrics&&) = delete;
283 Metrics&
284 operator=(Metrics&&) = delete;
285
286 void
289 average_bytes() const;
291 total_bytes() const;
292
293 private:
295 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
296 clock_type::time_point intervalStart_{clock_type::now()};
300 };
301
302 struct
303 {
307
308public:
309 PeerImp(PeerImp const&) = delete;
310 PeerImp&
311 operator=(PeerImp const&) = delete;
312
314 PeerImp(
315 Application& app,
316 id_t id,
318 http_request_type&& request,
319 PublicKey const& publicKey,
321 Resource::Consumer consumer,
322 std::unique_ptr<stream_type>&& stream_ptr,
323 OverlayImpl& overlay);
324
326 // VFALCO legacyPublicKey should be implied by the Slot
327 template <class Buffers>
328 PeerImp(
329 Application& app,
330 std::unique_ptr<stream_type>&& stream_ptr,
331 Buffers const& buffers,
333 http_response_type&& response,
334 Resource::Consumer usage,
335 PublicKey const& publicKey,
337 id_t id,
338 OverlayImpl& overlay);
339
340 virtual ~PeerImp();
341
342 beast::Journal const&
343 pjournal() const
344 {
345 return p_journal_;
346 }
347
350 {
351 return slot_;
352 }
353
354 // Work-around for calling shared_from_this in constructors
355 virtual void
356 run();
357
358 // Called when Overlay gets a stop request.
359 void
360 stop() override;
361
362 //
363 // Network
364 //
365
366 void
367 send(std::shared_ptr<Message> const& m) override;
368
370 void
371 sendTxQueue() override;
372
376 void
377 addTxQueue(uint256 const& hash) override;
378
382 void
383 removeTxQueue(uint256 const& hash) override;
384
386 template <
387 class FwdIt,
388 class = typename std::enable_if_t<std::is_same<
390 PeerFinder::Endpoint>::value>>
391 void
392 sendEndpoints(FwdIt first, FwdIt last);
393
395 getRemoteAddress() const override
396 {
397 return remote_address_;
398 }
399
400 void
401 charge(Resource::Charge const& fee, std::string const& context) override;
402
403 //
404 // Identity
405 //
406
408 id() const override
409 {
410 return id_;
411 }
412
414 bool
415 crawl() const;
416
417 bool
418 cluster() const override;
419
423 void
424 checkTracking(std::uint32_t validationSeq);
425
426 void
428
429 PublicKey const&
430 getNodePublic() const override
431 {
432 return publicKey_;
433 }
434
437 getVersion() const;
438
439 // Return the connection elapsed time.
440 clock_type::duration
441 uptime() const
442 {
444 }
445
447 json() override;
448
449 bool
450 supportsFeature(ProtocolFeature f) const override;
451
453 publisherListSequence(PublicKey const& pubKey) const override
454 {
456
457 auto iter = publisherListSequences_.find(pubKey);
458 if (iter != publisherListSequences_.end())
459 return iter->second;
460 return {};
461 }
462
463 void
465 override
466 {
468
469 publisherListSequences_[pubKey] = seq;
470 }
471
472 //
473 // Ledger
474 //
475
476 uint256 const&
477 getClosedLedgerHash() const override
478 {
479 return closedLedgerHash_;
480 }
481
482 bool
483 hasLedger(uint256 const& hash, std::uint32_t seq) const override;
484
485 void
486 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
487
488 bool
489 hasTxSet(uint256 const& hash) const override;
490
491 void
492 cycleStatus() override;
493
494 bool
495 hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
496
497 // Called to determine our priority for querying
498 int
499 getScore(bool haveItem) const override;
500
501 bool
502 isHighLatency() const override;
503
504 bool
505 compressionEnabled() const override
506 {
507 return compressionEnabled_ == Compressed::On;
508 }
509
510 bool
511 txReduceRelayEnabled() const override
512 {
514 }
515
516private:
531 void
532 fail(std::string const& name, error_code ec);
533
547 void
548 fail(std::string const& reason);
549
559 void
560 shutdown();
561
571 void
573
586 void
588
600 void
601 close();
602
612 void
614
625 void
626 onTimer(error_code const& ec);
627
634 void
635 cancelTimer() noexcept;
636
637 static std::string
638 makePrefix(id_t id);
639
640 void
641 doAccept();
642
643 std::string
644 name() const;
645
646 std::string
647 domain() const;
648
649 //
650 // protocol message loop
651 //
652
653 // Starts the protocol message loop
654 void
656
657 // Called when protocol message bytes are received
658 void
659 onReadMessage(error_code ec, std::size_t bytes_transferred);
660
661 // Called when protocol messages bytes are sent
662 void
663 onWriteMessage(error_code ec, std::size_t bytes_transferred);
664
677 void
679 std::shared_ptr<protocol::TMTransaction> const& m,
680 bool eraseTxQueue,
681 bool batch);
682
688 void
690 std::shared_ptr<protocol::TMHaveTransactions> const& m);
691
692public:
693 //--------------------------------------------------------------------------
694 //
695 // ProtocolStream
696 //
697 //--------------------------------------------------------------------------
698
699 void
700 onMessageUnknown(std::uint16_t type);
701
702 void
704 std::uint16_t type,
705 std::shared_ptr<::google::protobuf::Message> const& m,
706 std::size_t size,
707 std::size_t uncompressed_size,
708 bool isCompressed);
709
710 void
712 std::uint16_t type,
713 std::shared_ptr<::google::protobuf::Message> const& m);
714
715 void
716 onMessage(std::shared_ptr<protocol::TMManifests> const& m);
717 void
718 onMessage(std::shared_ptr<protocol::TMPing> const& m);
719 void
720 onMessage(std::shared_ptr<protocol::TMCluster> const& m);
721 void
722 onMessage(std::shared_ptr<protocol::TMEndpoints> const& m);
723 void
724 onMessage(std::shared_ptr<protocol::TMTransaction> const& m);
725 void
726 onMessage(std::shared_ptr<protocol::TMGetLedger> const& m);
727 void
728 onMessage(std::shared_ptr<protocol::TMLedgerData> const& m);
729 void
730 onMessage(std::shared_ptr<protocol::TMProposeSet> const& m);
731 void
732 onMessage(std::shared_ptr<protocol::TMStatusChange> const& m);
733 void
734 onMessage(std::shared_ptr<protocol::TMHaveTransactionSet> const& m);
735 void
736 onMessage(std::shared_ptr<protocol::TMValidatorList> const& m);
737 void
738 onMessage(std::shared_ptr<protocol::TMValidatorListCollection> const& m);
739 void
740 onMessage(std::shared_ptr<protocol::TMValidation> const& m);
741 void
742 onMessage(std::shared_ptr<protocol::TMGetObjectByHash> const& m);
743 void
744 onMessage(std::shared_ptr<protocol::TMHaveTransactions> const& m);
745 void
746 onMessage(std::shared_ptr<protocol::TMTransactions> const& m);
747 void
748 onMessage(std::shared_ptr<protocol::TMSquelch> const& m);
749 void
750 onMessage(std::shared_ptr<protocol::TMProofPathRequest> const& m);
751 void
752 onMessage(std::shared_ptr<protocol::TMProofPathResponse> const& m);
753 void
754 onMessage(std::shared_ptr<protocol::TMReplayDeltaRequest> const& m);
755 void
756 onMessage(std::shared_ptr<protocol::TMReplayDeltaResponse> const& m);
757
758private:
759 //--------------------------------------------------------------------------
760 // lockedRecentLock is passed as a reminder to callers that recentLock_
761 // must be locked.
762 void
763 addLedger(
764 uint256 const& hash,
765 std::lock_guard<std::mutex> const& lockedRecentLock);
766
767 void
768 doFetchPack(std::shared_ptr<protocol::TMGetObjectByHash> const& packet);
769
770 void
772 std::string const& messageType,
773 std::string const& manifest,
774 std::uint32_t version,
775 std::vector<ValidatorBlobInfo> const& blobs);
776
781 void
782 doTransactions(std::shared_ptr<protocol::TMGetObjectByHash> const& packet);
783
784 void
786 HashRouterFlags flags,
787 bool checkSignature,
788 std::shared_ptr<STTx const> const& stx,
789 bool batch);
790
791 void
793 bool isTrusted,
794 std::shared_ptr<protocol::TMProposeSet> const& packet,
795 RCLCxPeerPos peerPos);
796
797 void
799 std::shared_ptr<STValidation> const& val,
800 uint256 const& key,
801 std::shared_ptr<protocol::TMValidation> const& packet);
802
803 void
805 std::shared_ptr<Ledger const> const& ledger,
806 protocol::TMLedgerData& ledgerData);
807
808 std::shared_ptr<Ledger const>
809 getLedger(std::shared_ptr<protocol::TMGetLedger> const& m);
810
811 std::shared_ptr<SHAMap const>
812 getTxSet(std::shared_ptr<protocol::TMGetLedger> const& m) const;
813
814 void
815 processLedgerRequest(std::shared_ptr<protocol::TMGetLedger> const& m);
816};
817
818//------------------------------------------------------------------------------
819
820template <class Buffers>
822 Application& app,
823 std::unique_ptr<stream_type>&& stream_ptr,
824 Buffers const& buffers,
825 std::shared_ptr<PeerFinder::Slot>&& slot,
826 http_response_type&& response,
827 Resource::Consumer usage,
828 PublicKey const& publicKey,
830 id_t id,
831 OverlayImpl& overlay)
832 : Child(overlay)
833 , app_(app)
834 , id_(id)
835 , sink_(app_.journal("Peer"), makePrefix(id))
836 , p_sink_(app_.journal("Protocol"), makePrefix(id))
837 , journal_(sink_)
839 , stream_ptr_(std::move(stream_ptr))
840 , socket_(stream_ptr_->next_layer().socket())
842 , strand_(boost::asio::make_strand(socket_.get_executor()))
843 , timer_(waitable_timer{socket_.get_executor()})
844 , remote_address_(slot->remote_endpoint())
845 , overlay_(overlay)
846 , inbound_(false)
850 , publicKey_(publicKey)
853 , squelch_(app_.journal("Squelch"))
854 , usage_(usage)
856 , slot_(std::move(slot))
857 , response_(std::move(response))
861 headers_,
863 "lz4",
865 ? Compressed::On
866 : Compressed::Off)
868 headers_,
870 app_.config().TX_REDUCE_RELAY_ENABLE))
872 headers_,
874 app_.config().LEDGER_REPLAY))
875 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
876{
877 read_buffer_.commit(boost::asio::buffer_copy(
878 read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
879 JLOG(journal_.info())
880 << "compression enabled " << (compressionEnabled_ == Compressed::On)
881 << " vp reduce-relay base squelch enabled "
883 headers_,
886 << " tx reduce-relay enabled " << txReduceRelayEnabled_ << " on "
887 << remote_address_ << " " << id_;
888}
889
890template <class FwdIt, class>
891void
892PeerImp::sendEndpoints(FwdIt first, FwdIt last)
893{
894 protocol::TMEndpoints tm;
895
896 while (first != last)
897 {
898 auto& tme2(*tm.add_endpoints_v2());
899 tme2.set_endpoint(first->address.to_string());
900 tme2.set_hops(first->hops);
901 first++;
902 }
903 tm.set_version(2);
904
905 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
906}
907
908} // namespace ripple
909
910#endif
Represents a JSON value.
Definition json_value.h:149
A version-independent IP address and port combination.
Definition IPEndpoint.h:38
A generic endpoint for log messages.
Definition Journal.h:60
Stream info() const
Definition Journal.h:334
Wraps a Journal::Sink to prefix its output with a string.
Definition WrappedSink.h:34
virtual Config & config()=0
virtual beast::Journal journal(std::string const &name)=0
bool VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE
Definition Config.h:248
bool COMPRESSION
Definition Config.h:220
Holds a ledger.
Definition Ledger.h:80
Child(OverlayImpl &overlay)
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition PeerImp.h:295
std::uint64_t accumBytes_
Definition PeerImp.h:298
Metrics & operator=(Metrics const &)=delete
Metrics(Metrics &&)=delete
std::uint64_t total_bytes() const
Definition PeerImp.cpp:3650
std::uint64_t totalBytes_
Definition PeerImp.h:297
Metrics & operator=(Metrics &&)=delete
std::uint64_t average_bytes() const
Definition PeerImp.cpp:3643
void add_message(std::uint64_t bytes)
Definition PeerImp.cpp:3617
Metrics(Metrics const &)=delete
std::shared_mutex mutex_
Definition PeerImp.h:294
std::uint64_t rollingAvgBytes_
Definition PeerImp.h:299
clock_type::time_point intervalStart_
Definition PeerImp.h:296
This class manages established peer-to-peer connections, handles message exchange,...
Definition PeerImp.h:118
std::queue< std::shared_ptr< Message > > send_queue_
Definition PeerImp.h:241
boost::beast::ssl_stream< middle_type > stream_type
Definition PeerImp.h:128
PeerImp & operator=(PeerImp const &)=delete
std::unique_ptr< LoadEvent > load_event_
Definition PeerImp.h:256
boost::beast::http::fields const & headers_
Definition PeerImp.h:240
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
Definition PeerImp.cpp:2136
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition PeerImp.cpp:1160
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition PeerImp.cpp:527
Metrics sent
Definition PeerImp.h:304
clock_type::duration uptime() const
Definition PeerImp.h:441
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition PeerImp.cpp:343
protocol::TMStatusChange last_status_
Definition PeerImp.h:233
std::string name_
Definition PeerImp.h:165
boost::circular_buffer< uint256 > recentTxSets_
Definition PeerImp.h:176
std::unique_ptr< stream_type > stream_ptr_
Definition PeerImp.h:141
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition PeerImp.cpp:1169
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition PeerImp.h:121
Compressed compressionEnabled_
Definition PeerImp.h:261
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition PeerImp.h:453
uint256 closedLedgerHash_
Definition PeerImp.h:172
std::string domain() const
Definition PeerImp.cpp:902
std::optional< std::uint32_t > lastPingSeq_
Definition PeerImp.h:179
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition PeerImp.h:349
http_response_type response_
Definition PeerImp.h:239
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition PeerImp.h:892
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition PeerImp.cpp:3222
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Definition PeerImp.cpp:2855
boost::asio::ip::tcp::endpoint endpoint_type
Definition PeerImp.h:130
beast::Journal const journal_
Definition PeerImp.h:139
virtual void run()
Definition PeerImp.cpp:161
boost::asio::ip::address address_type
Definition PeerImp.h:129
struct ripple::PeerImp::@21 metrics_
void tryAsyncShutdown()
Attempts to perform a graceful SSL shutdown if conditions are met.
Definition PeerImp.cpp:622
LedgerIndex maxLedger_
Definition PeerImp.h:171
beast::Journal const p_journal_
Definition PeerImp.h:140
bool const inbound_
Definition PeerImp.h:156
PeerImp(PeerImp const &)=delete
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition PeerImp.cpp:3393
Application & app_
Definition PeerImp.h:135
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition PeerImp.cpp:3358
void stop() override
Definition PeerImp.cpp:219
void shutdown()
Initiates the peer disconnection sequence.
Definition PeerImp.cpp:646
void checkTransaction(HashRouterFlags flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
Definition PeerImp.cpp:2944
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition PeerImp.cpp:569
bool hasTxSet(uint256 const &hash) const override
Definition PeerImp.cpp:551
clock_type::time_point lastPingTime_
Definition PeerImp.h:180
void onMessageUnknown(std::uint16_t type)
Definition PeerImp.cpp:1111
std::shared_ptr< PeerFinder::Slot > const slot_
Definition PeerImp.h:236
std::shared_mutex nameMutex_
Definition PeerImp.h:166
boost::circular_buffer< uint256 > recentLedgers_
Definition PeerImp.h:175
id_t const id_
Definition PeerImp.h:136
std::optional< std::chrono::milliseconds > latency_
Definition PeerImp.h:178
compression::Compressed Compressed
Definition PeerImp.h:133
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
Called from onMessage(TMTransaction(s)).
Definition PeerImp.cpp:1361
beast::IP::Endpoint const remote_address_
Definition PeerImp.h:151
boost::asio::ip::tcp::socket socket_type
Definition PeerImp.h:126
Json::Value json() override
Definition PeerImp.cpp:392
PublicKey const publicKey_
Definition PeerImp.h:164
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition PeerImp.cpp:2839
void close()
Forcibly closes the underlying socket connection.
Definition PeerImp.cpp:689
hash_set< uint256 > txQueue_
Definition PeerImp.h:266
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition PeerImp.cpp:3262
std::mutex recentLock_
Definition PeerImp.h:232
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:1117
bool txReduceRelayEnabled_
Definition PeerImp.h:268
beast::IP::Endpoint getRemoteAddress() const override
Definition PeerImp.h:395
Metrics recv
Definition PeerImp.h:305
void fail(std::string const &name, error_code ec)
Handles a failure associated with a specific error code.
Definition PeerImp.cpp:579
clock_type::time_point trackingTime_
Definition PeerImp.h:162
void cancelTimer() noexcept
Cancels any pending wait on the peer activity timer.
Definition PeerImp.cpp:801
bool shutdownStarted_
Definition PeerImp.h:247
socket_type & socket_
Definition PeerImp.h:142
ProtocolVersion protocol_
Definition PeerImp.h:159
clock_type::time_point const creationTime_
Definition PeerImp.h:181
reduce_relay::Squelch< UptimeClock > squelch_
Definition PeerImp.h:183
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition PeerImp.h:259
bool writePending_
Definition PeerImp.h:253
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition PeerImp.cpp:384
uint256 previousLedgerHash_
Definition PeerImp.h:173
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:355
boost::beast::tcp_stream middle_type
Definition PeerImp.h:127
int getScore(bool haveItem) const override
Definition PeerImp.cpp:3572
void onTimer(error_code const &ec)
Handles the expiration of the peer activity timer.
Definition PeerImp.cpp:734
void send(std::shared_ptr< Message > const &m) override
Definition PeerImp.cpp:239
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
Definition PeerImp.cpp:2889
static std::string makePrefix(id_t id)
Definition PeerImp.cpp:814
std::string name() const
Definition PeerImp.cpp:895
boost::system::error_code error_code
Definition PeerImp.h:125
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition PeerImp.cpp:954
bool ledgerReplayEnabled_
Definition PeerImp.h:270
beast::WrappedSink p_sink_
Definition PeerImp.h:138
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition PeerImp.h:132
PublicKey const & getNodePublic() const override
Definition PeerImp.h:430
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition PeerImp.cpp:369
waitable_timer timer_
Definition PeerImp.h:147
beast::Journal const & pjournal() const
Definition PeerImp.h:343
void setTimer(std::chrono::seconds interval)
Sets and starts the peer timer.
Definition PeerImp.cpp:715
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition PeerImp.cpp:307
bool compressionEnabled() const override
Definition PeerImp.h:505
bool txReduceRelayEnabled() const override
Definition PeerImp.h:511
bool supportsFeature(ProtocolFeature f) const override
Definition PeerImp.cpp:510
uint256 const & getClosedLedgerHash() const override
Definition PeerImp.h:477
beast::WrappedSink sink_
Definition PeerImp.h:137
ChargeWithContext fee_
Definition PeerImp.h:235
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition PeerImp.cpp:1045
http_request_type request_
Definition PeerImp.h:238
OverlayImpl & overlay_
Definition PeerImp.h:155
LedgerIndex minLedger_
Definition PeerImp.h:170
virtual ~PeerImp()
Definition PeerImp.cpp:138
Peer::id_t id() const override
Definition PeerImp.h:408
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition PeerImp.h:271
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:2719
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition PeerImp.cpp:326
stream_type & stream_
Definition PeerImp.h:143
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition PeerImp.cpp:378
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition PeerImp.cpp:3082
bool isHighLatency() const override
Definition PeerImp.cpp:3610
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition PeerImp.cpp:2069
void onShutdown(error_code ec)
Handles the completion of the asynchronous SSL shutdown.
Definition PeerImp.cpp:663
boost::asio::strand< boost::asio::executor > strand_
Definition PeerImp.h:144
void cycleStatus() override
Definition PeerImp.cpp:559
boost::beast::multi_buffer read_buffer_
Definition PeerImp.h:237
Resource::Consumer usage_
Definition PeerImp.h:234
void checkValidation(std::shared_ptr< STValidation > const &val, uint256 const &key, std::shared_ptr< protocol::TMValidation > const &packet)
Definition PeerImp.cpp:3125
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition PeerImp.h:464
bool readPending_
Definition PeerImp.h:250
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition PeerImp.cpp:542
void doProtocolStart()
Definition PeerImp.cpp:912
std::atomic< Tracking > tracking_
Definition PeerImp.h:161
Represents a peer connection in the overlay.
std::uint32_t id_t
Uniquely identifies a peer.
A public key.
Definition PublicKey.h:61
A peer's signed, proposed position for use in RCLConsensus.
A consumption charge.
Definition Charge.h:30
An endpoint that consumes resources.
Definition Consumer.h:35
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
Definition SHAMap.h:99
Maintains squelching of relaying messages from validators.
Definition Squelch.h:39
T empty(T... args)
Charge const feeTrivialPeer
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
Definition Handoff.h:36
static constexpr char FEATURE_COMPR[]
Definition Handshake.h:141
static constexpr char FEATURE_LEDGER_REPLAY[]
Definition Handshake.h:147
HashRouterFlags
Definition HashRouter.h:34
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition Handoff.h:33
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:198
static constexpr char FEATURE_TXRR[]
Definition Handshake.h:145
@ manifest
Manifest.
static constexpr char FEATURE_VPRR[]
Definition Handshake.h:143
STL namespace.
Describes a connectible peer address along with some metadata.
void update(Resource::Charge f, std::string const &add)
Definition PeerImp.h:218
Used to represent the information stored in the blobs_v2 Json array.