xrpld
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/app/main/Application.h>
6#include <xrpld/overlay/Compression.h>
7#include <xrpld/overlay/Message.h>
8#include <xrpld/overlay/Peer.h>
9#include <xrpld/overlay/Squelch.h>
10#include <xrpld/overlay/detail/OverlayImpl.h>
11#include <xrpld/overlay/detail/ProtocolVersion.h>
12
13#include <xrpl/basics/Log.h>
14#include <xrpl/basics/Number.h>
15#include <xrpl/basics/UnorderedContainers.h>
16#include <xrpl/basics/UptimeClock.h>
17#include <xrpl/basics/base_uint.h>
18#include <xrpl/beast/net/IPEndpoint.h>
19#include <xrpl/beast/utility/Journal.h>
20#include <xrpl/beast/utility/WrappedSink.h>
21#include <xrpl/beast/utility/instrumentation.h>
22#include <xrpl/core/HashRouter.h>
23#include <xrpl/core/LoadEvent.h>
24#include <xrpl/json/json_value.h>
25#include <xrpl/peerfinder/Slot.h>
26#include <xrpl/peerfinder/Types.h>
27#include <xrpl/protocol/Protocol.h>
28#include <xrpl/protocol/PublicKey.h>
29#include <xrpl/protocol/STTx.h>
30#include <xrpl/protocol/STValidation.h>
31#include <xrpl/resource/Charge.h>
32#include <xrpl/resource/Consumer.h>
33#include <xrpl/resource/Fees.h>
34#include <xrpl/server/Handoff.h>
35#include <xrpl/server/Manifest.h>
36#include <xrpl/shamap/SHAMapNodeID.h>
37
38#include <boost/circular_buffer.hpp>
39#include <boost/endian/conversion.hpp>
40#include <boost/thread/shared_mutex.hpp>
41
42#include <google/protobuf/message.h>
43
44#include <xrpl.pb.h>
45
46#include <atomic>
47#include <chrono>
48#include <cstddef>
49#include <cstdint>
50#include <iterator>
51#include <memory>
52#include <mutex>
53#include <optional>
54#include <queue>
55#include <shared_mutex>
56#include <string>
57#include <type_traits>
58#include <utility>
59#include <vector>
60
61namespace xrpl {
62
64class SHAMap;
65
66class PeerImp : public Peer, public std::enable_shared_from_this<PeerImp>, public OverlayImpl::Child
67{
68public:
73
74private:
76 using error_code = boost::system::error_code;
77 using socket_type = boost::asio::ip::tcp::socket;
78 using middle_type = boost::beast::tcp_stream;
79 using stream_type = boost::beast::ssl_stream<middle_type>;
80 using address_type = boost::asio::ip::address;
81 using endpoint_type = boost::asio::ip::tcp::endpoint;
82 using waitable_timer = boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
84
86 id_t const id_;
96 boost::asio::strand<boost::asio::executor> strand_;
98
99 // Updated at each stage of the connection process to reflect
100 // the current conditions as closely as possible.
102
103 // These are up here to prevent warnings about order of initializations
104 //
106 bool const inbound_;
107
108 // Protocol version to use for this link
110
112 clock_type::time_point trackingTime_;
113 bool detaching_ = false;
114 // Node public key of peer.
118
119 // The indices of the smallest and largest ledgers this peer has available
120 //
125
126 boost::circular_buffer<uint256> recentLedgers_{128};
127 boost::circular_buffer<uint256> recentTxSets_{128};
128
131 clock_type::time_point lastPingTime_;
132 clock_type::time_point const creationTime_;
133
135
136 // Notes on thread locking:
137 //
138 // During an audit it was noted that some member variables that looked
139 // like they need thread protection were not receiving it. And, indeed,
140 // that was correct. But the multi-phase initialization of PeerImp
141 // makes such an audit difficult. A further audit suggests that the
142 // locking is now protecting variables that don't need it. We're
143 // leaving that locking in place (for now) as a form of future proofing.
144 //
145 // Here are the variables that appear to need locking currently:
146 //
147 // o closedLedgerHash_
148 // o previousLedgerHash_
149 // o minLedger_
150 // o maxLedger_
151 // o recentLedgers_
152 // o recentTxSets_
153 // o trackingTime_
154 // o latency_
155 //
156 // The following variables are being protected preemptively:
157 //
158 // o name_
159 // o lastStatus_
160 //
161 // June 2019
162
164 {
166 std::string context{}; // NOLINT(readability-redundant-member-init)
167
168 void
170 {
171 XRPL_ASSERT(f >= fee, "xrpl::PeerImp::ChargeWithContext::update : fee increases");
172 fee = f;
173 if (!context.empty())
174 {
175 context += " ";
176 }
177 context += add;
178 }
179 };
180
182 protocol::TMStatusChange lastStatus_;
185
186 // One-shot guard so concurrent JobQueue workers cannot double-count
187 // the per-connection peer-disconnect-by-charge metric (and cannot
188 // post duplicate fail() calls) when several queued requests cross
189 // kDropThreshold before the first fail() lands on the strand.
192 boost::beast::multi_buffer readBuffer_;
195 boost::beast::http::fields const& headers_;
197 bool gracefulClose_ = false;
198 int largeSendq_ = 0;
200 // The highest sequence of each PublisherList that has
201 // been sent to or received from this peer.
203
205
206 // Queue of transactions' hashes that have not been
207 // relayed. The hashes are sent once a second to a peer
208 // and the peer requests missing transactions from the node.
210 // true if tx reduce-relay feature is enabled on the peer.
212
215
216 friend class OverlayImpl;
217
219 {
220 public:
221 Metrics() = default;
222 Metrics(Metrics const&) = delete;
223 Metrics&
224 operator=(Metrics const&) = delete;
225 Metrics(Metrics&&) = delete;
226 Metrics&
227 operator=(Metrics&&) = delete;
228
229 void
232 averageBytes() const;
234 totalBytes() const;
235
236 private:
238 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
239 clock_type::time_point intervalStart_{clock_type::now()};
243 };
244
245 struct
246 {
250
251public:
252 PeerImp(PeerImp const&) = delete;
253 PeerImp&
254 operator=(PeerImp const&) = delete;
255
259 PeerImp(
260 Application& app,
261 id_t id,
263 http_request_type&& request,
264 PublicKey const& publicKey,
266 resource::Consumer consumer,
268 OverlayImpl& overlay);
269
273 // VFALCO legacyPublicKey should be implied by the Slot
274 template <class Buffers>
275 PeerImp(
276 Application& app,
278 Buffers const& buffers,
280 http_response_type&& response,
281 resource::Consumer usage,
282 PublicKey const& publicKey,
284 id_t id,
285 OverlayImpl& overlay);
286
287 ~PeerImp() override;
288
289 beast::Journal const&
290 pJournal() const
291 {
292 return pJournal_;
293 }
294
297 {
298 return slot_;
299 }
300
301 // Work-around for calling shared_from_this in constructors
302 virtual void
303 run();
304
305 // Called when Overlay gets a stop request.
306 void
307 stop() override;
308
309 //
310 // Network
311 //
312
313 void
314 send(std::shared_ptr<Message> const& m) override;
315
319 void
320 sendTxQueue() override;
321
326 void
327 addTxQueue(uint256 const& hash) override;
328
333 void
334 removeTxQueue(uint256 const& hash) override;
335
339 template <class FwdIt>
340 void
341 sendEndpoints(FwdIt first, FwdIt last)
342 requires(
346
348 getRemoteAddress() const override
349 {
350 return remoteAddress_;
351 }
352
353 void
354 charge(resource::Charge const& fee, std::string const& context) override;
355
356 //
357 // Identity
358 //
359
361 id() const override
362 {
363 return id_;
364 }
365
369 bool
370 crawl() const;
371
372 bool
373 cluster() const override;
374
379 void
380 checkTracking(std::uint32_t validationSeq);
381
382 void
384
385 PublicKey const&
386 getNodePublic() const override
387 {
388 return publicKey_;
389 }
390
395 getVersion() const;
396
397 // Return the connection elapsed time.
398 clock_type::duration
399 uptime() const
400 {
402 }
403
405 json() override;
406
407 bool
408 supportsFeature(ProtocolFeature f) const override;
409
411 publisherListSequence(PublicKey const& pubKey) const override
412 {
414
415 auto iter = publisherListSequences_.find(pubKey);
416 if (iter != publisherListSequences_.end())
417 return iter->second;
418 return {};
419 }
420
421 void
422 setPublisherListSequence(PublicKey const& pubKey, std::size_t const seq) override
423 {
425
426 publisherListSequences_[pubKey] = seq;
427 }
428
429 //
430 // Ledger
431 //
432
433 uint256
434 getClosedLedgerHash() const override
435 {
437 return closedLedgerHash_;
438 }
439
440 bool
441 hasLedger(uint256 const& hash, std::uint32_t seq) const override;
442
443 void
444 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
445
446 bool
447 hasTxSet(uint256 const& hash) const override;
448
449 void
450 cycleStatus() override;
451
452 bool
453 hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
454
455 // Called to determine our priority for querying
456 int
457 getScore(bool haveItem) const override;
458
459 bool
460 isHighLatency() const override;
461
462 void
463 fail(std::string const& reason);
464
465 bool
466 compressionEnabled() const override
467 {
468 return compressionEnabled_ == Compressed::On;
469 }
470
478 [[nodiscard]] std::size_t
480 {
482 trustedManifestCount(app_.config().maxTrustedCount),
483 untrustedManifestCount(app_.config().maxUntrustedCount));
484 }
485
486 bool
487 txReduceRelayEnabled() const override
488 {
490 }
491
492private:
493 void
494 close();
495
496 void
497 fail(std::string const& name, error_code ec);
498
499 void
501
502 void
503 setTimer();
504
505 void
506 cancelTimer() noexcept;
507
508 static std::string
509 makePrefix(std::string const& fingerprint);
510
511 // Called when the timer wait completes
512 void
513 onTimer(boost::system::error_code const& ec);
514
515 // Called when SSL shutdown completes
516 void
518
519 void
520 doAccept();
521
522 std::string
523 name() const;
524
525 std::string
526 domain() const;
527
528 //
529 // protocol message loop
530 //
531
532 // Starts the protocol message loop
533 void
535
536 // Called when protocol message bytes are received
537 void
538 onReadMessage(error_code ec, std::size_t bytesTransferred);
539
540 // Called when protocol messages bytes are sent
541 void
542 onWriteMessage(error_code ec, std::size_t bytesTransferred);
543
557 void
559 std::shared_ptr<protocol::TMTransaction> const& m,
560 bool eraseTxQueue,
561 bool batch);
562
569 void
570 handleHaveTransactions(std::shared_ptr<protocol::TMHaveTransactions> const& m);
571
572 std::string const&
573 fingerprint() const override
574 {
575 return fingerprint_;
576 }
577
578 std::string const&
579 prefix() const
580 {
581 return prefix_;
582 }
583
584public:
585 //--------------------------------------------------------------------------
586 //
587 // ProtocolStream
588 //
589 //--------------------------------------------------------------------------
590
591 void
593
594 void
596 std::uint16_t type,
598 std::size_t size,
599 std::size_t uncompressedSize,
600 bool isCompressed);
601
602 void
604
605 void
607 void
609 void
611 void
613 void
615 void
617 void
619 void
621 void
623 void
625 void
627 void
629 void
631 void
633 void
635 void
637 void
639 void
641 void
643 void
645
646private:
647 //--------------------------------------------------------------------------
648 // lockedRecentLock is passed as a reminder to callers that recentLock_
649 // must be locked.
650 void
651 addLedger(uint256 const& hash, std::scoped_lock<std::mutex> const& lockedRecentLock);
652
653 void
655
656 void
658 std::string const& messageType,
659 std::string const& manifest,
660 std::uint32_t version,
661 std::vector<ValidatorBlobInfo> const& blobs);
662
668 void
670
671 void
673 HashRouterFlags flags,
674 bool checkSignature,
676 bool batch);
677
678 void
680 bool isTrusted,
682 RCLCxPeerPos peerPos);
683
684 void
687 uint256 const& key,
689
690 void
691 sendLedgerBase(std::shared_ptr<Ledger const> const& ledger, protocol::TMLedgerData& ledgerData);
692
695
698
699 void
703
704protected:
705 // Kept `protected` so test subclasses (see
706 // TMGetObjectByHash_test) can drive the
707 // synchronous processor and the differential-pricing helper without
708 // routing through the JobQueue or going through `friend` plumbing.
709 // Production callers reach these members only via
710 // `onMessage(TMGetObjectByHash)` → JobQueue → `processGetObjectByHash`.
711
723 void
725
749 static resource::Charge
750 computeGetObjectByHashFee(int const requested, int const found);
751
764 {
765 return fee_.fee;
766 }
767};
768
769//------------------------------------------------------------------------------
770
771template <class Buffers>
773 Application& app,
775 Buffers const& buffers,
777 http_response_type&& response,
778 resource::Consumer usage,
779 PublicKey const& publicKey,
781 id_t id,
782 OverlayImpl& overlay)
783 : Child(overlay)
784 , app_(app)
785 , id_(id)
786 , fingerprint_(getFingerprint(slot->remoteEndpoint(), publicKey, to_string(id_)))
788 , sink_(app_.getJournal("Peer"), prefix_)
789 , pSink_(app_.getJournal("Protocol"), prefix_)
790 , journal_(sink_)
792 , streamPtr_(std::move(streamPtr))
793 , socket_(streamPtr_->next_layer().socket())
795 , strand_(boost::asio::make_strand(socket_.get_executor()))
796 , timer_(waitable_timer{socket_.get_executor()})
797 , remoteAddress_(slot->remoteEndpoint())
798 , overlay_(overlay)
799 , inbound_(false)
800 , protocol_(std::move(protocol))
802 , trackingTime_(clock_type::now())
803 , publicKey_(publicKey)
804 , lastPingTime_(clock_type::now())
805 , creationTime_(clock_type::now())
806 , squelch_(app_.getJournal("Squelch"))
807 , usage_(usage)
808 , fee_{.fee = resource::kFeeTrivialPeer}
809 , slot_(std::move(slot))
810 , response_(std::move(response))
814 ? Compressed::On
815 : Compressed::Off)
817 peerFeatureEnabled(headers_, kFeatureTxrr, app_.config().txReduceRelayEnable))
819 peerFeatureEnabled(headers_, kFeatureLedgerReplay, app_.config().ledgerReplay))
820 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
821{
822 readBuffer_.commit(
823 boost::asio::buffer_copy(readBuffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
824 JLOG(journal_.info())
825 << "compression enabled " << (compressionEnabled_ == Compressed::On)
826 << " vp reduce-relay base squelch enabled "
827 << peerFeatureEnabled(headers_, kFeatureVprr, app_.config().vpReduceRelayBaseSquelchEnable)
828 << " tx reduce-relay enabled " << txReduceRelayEnabled_ << " on " << remoteAddress_ << " "
829 << id_;
830}
831
832template <class FwdIt>
833void
834PeerImp::sendEndpoints(FwdIt first, FwdIt last)
835 requires(
837{
838 protocol::TMEndpoints tm;
839
840 while (first != last)
841 {
842 auto& tme2(*tm.add_endpoints_v2());
843 tme2.set_endpoint(first->address.toString());
844 tme2.set_hops(first->hops);
845 first++;
846 }
847 tm.set_version(2);
848
849 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
850}
851
852} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
Wraps a Journal::Sink to prefix its output with a string.
Definition WrappedSink.h:19
A version-independent IP address and port combination.
Definition IPEndpoint.h:24
Represents a JSON value.
Definition json_value.h:117
Child(OverlayImpl &overlay)
std::shared_mutex mutex_
Definition PeerImp.h:237
std::uint64_t rollingAvgBytes_
Definition PeerImp.h:242
clock_type::time_point intervalStart_
Definition PeerImp.h:239
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition PeerImp.h:238
Metrics(Metrics const &)=delete
void addMessage(std::uint64_t bytes)
Definition PeerImp.cpp:3713
Metrics & operator=(Metrics const &)=delete
Metrics & operator=(Metrics &&)=delete
std::uint64_t averageBytes() const
Definition PeerImp.cpp:3737
Metrics(Metrics &&)=delete
std::uint64_t totalBytes() const
Definition PeerImp.cpp:3744
std::uint64_t accumBytes_
Definition PeerImp.h:241
std::uint64_t totalBytes_
Definition PeerImp.h:240
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition PeerImp.cpp:2161
void onTimer(boost::system::error_code const &ec)
Definition PeerImp.cpp:702
std::optional< std::chrono::milliseconds > latency_
Definition PeerImp.h:129
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition PeerImp.cpp:354
std::string getVersion() const
Return the version of xrpld that the peer is running, if reported.
Definition PeerImp.cpp:419
std::size_t maxManifestsMessageSize() const
Largest TMManifests message this node accepts, in bytes.
Definition PeerImp.h:479
boost::asio::ip::tcp::endpoint endpoint_type
Definition PeerImp.h:81
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition PeerImp.cpp:1094
ProtocolVersion protocol_
Definition PeerImp.h:109
bool txReduceRelayEnabled_
Definition PeerImp.h:211
void checkTransaction(HashRouterFlags flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
Definition PeerImp.cpp:3006
void setTimer()
Definition PeerImp.cpp:662
boost::beast::tcp_stream middle_type
Definition PeerImp.h:78
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
Called from onMessage(TMTransaction(s)).
Definition PeerImp.cpp:1292
http_request_type request_
Definition PeerImp.h:193
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition PeerImp.cpp:369
beast::WrappedSink sink_
Definition PeerImp.h:89
std::string name() const
Definition PeerImp.cpp:862
bool txReduceRelayEnabled() const override
Definition PeerImp.h:487
boost::asio::ip::tcp::socket socket_type
Definition PeerImp.h:77
compression::Compressed Compressed
Definition PeerImp.h:83
boost::beast::http::fields const & headers_
Definition PeerImp.h:195
Compressed compressionEnabled_
Definition PeerImp.h:204
std::chrono::steady_clock clock_type
Definition PeerImp.h:75
boost::system::error_code error_code
Definition PeerImp.h:76
PeerImp & operator=(PeerImp const &)=delete
LedgerIndex minLedger_
Definition PeerImp.h:121
std::string prefix_
Definition PeerImp.h:88
std::shared_ptr< peer_finder::Slot > const slot_
Definition PeerImp.h:191
void addLedger(uint256 const &hash, std::scoped_lock< std::mutex > const &lockedRecentLock)
Definition PeerImp.cpp:2908
boost::beast::multi_buffer readBuffer_
Definition PeerImp.h:192
id_t const id_
Definition PeerImp.h:86
Metrics sent
Definition PeerImp.h:247
std::string const & fingerprint() const override
Definition PeerImp.h:573
bool ledgerReplayEnabled_
Definition PeerImp.h:213
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition PeerImp.cpp:338
struct xrpl::PeerImp::@337373043150231020277011015352151251117171316327 metrics_
beast::ip::Endpoint const remoteAddress_
Definition PeerImp.h:101
std::unique_ptr< stream_type > streamPtr_
Definition PeerImp.h:93
uint256 closedLedgerHash_
Definition PeerImp.h:123
reduce_relay::Squelch< UptimeClock > squelch_
Definition PeerImp.h:134
stream_type & stream_
Definition PeerImp.h:95
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:3187
void cycleStatus() override
Definition PeerImp.cpp:586
bool gracefulClose_
Definition PeerImp.h:197
uint256 getClosedLedgerHash() const override
Definition PeerImp.h:434
std::shared_mutex nameMutex_
Definition PeerImp.h:117
socket_type & socket_
Definition PeerImp.h:94
std::string domain() const
Definition PeerImp.cpp:869
std::atomic< Tracking > tracking_
Definition PeerImp.h:111
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition PeerImp.h:411
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition PeerImp.cpp:570
clock_type::duration uptime() const
Definition PeerImp.h:399
boost::asio::ip::address address_type
Definition PeerImp.h:80
LedgerIndex maxLedger_
Definition PeerImp.h:122
beast::WrappedSink pSink_
Definition PeerImp.h:90
Application & app_
Definition PeerImp.h:85
PublicKey const publicKey_
Definition PeerImp.h:115
void processGetObjectByHash(std::shared_ptr< protocol::TMGetObjectByHash > const &m)
Process a generic-query TMGetObjectByHash message.
Definition PeerImp.cpp:2715
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition PeerImp.cpp:413
Metrics recv
Definition PeerImp.h:248
static resource::Charge computeGetObjectByHashFee(int const requested, int const found)
Compute the per-message resource charge for a TMGetObjectByHash request based on how much work was ac...
Definition PeerImp.cpp:3638
std::queue< std::shared_ptr< Message > > sendQueue_
Definition PeerImp.h:196
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition PeerImp.cpp:3139
virtual void run()
Definition PeerImp.cpp:205
OverlayImpl & overlay_
Definition PeerImp.h:105
resource::Consumer usage_
Definition PeerImp.h:183
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition PeerImp.cpp:3278
Peer::id_t id() const override
Definition PeerImp.h:361
beast::Journal const pJournal_
Definition PeerImp.h:92
friend class OverlayImpl
Definition PeerImp.h:216
static std::string makePrefix(std::string const &fingerprint)
Definition PeerImp.cpp:694
beast::Journal const & pJournal() const
Definition PeerImp.h:290
ChargeWithContext fee_
Definition PeerImp.h:184
void onShutdown(error_code ec)
Definition PeerImp.cpp:762
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:2795
beast::ip::Endpoint getRemoteAddress() const override
Definition PeerImp.h:348
void onMessageUnknown(std::uint16_t type)
Definition PeerImp.cpp:1041
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m, std::vector< SHAMapNodeID > nodeIDs)
Definition PeerImp.cpp:3431
~PeerImp() override
Definition PeerImp.cpp:182
void gracefulClose()
Definition PeerImp.cpp:647
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition PeerImp.h:422
bool compressionEnabled() const override
Definition PeerImp.h:466
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition PeerImp.h:72
protocol::TMStatusChange lastStatus_
Definition PeerImp.h:182
clock_type::time_point const creationTime_
Definition PeerImp.h:132
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition PeerImp.h:214
void fail(std::string const &reason)
Definition PeerImp.cpp:622
std::unique_ptr< LoadEvent > loadEvent_
Definition PeerImp.h:199
void send(std::shared_ptr< Message > const &m) override
Definition PeerImp.cpp:276
void onMessageBegin(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m, std::size_t size, std::size_t uncompressedSize, bool isCompressed)
Definition PeerImp.cpp:1047
hash_set< uint256 > txQueue_
Definition PeerImp.h:209
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Definition PeerImp.cpp:2921
bool supportsFeature(ProtocolFeature f) const override
Definition PeerImp.cpp:541
void doProtocolStart()
Definition PeerImp.cpp:879
PublicKey const & getNodePublic() const override
Definition PeerImp.h:386
int largeSendq_
Definition PeerImp.h:198
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition PeerImp.cpp:3315
bool const inbound_
Definition PeerImp.h:106
boost::asio::strand< boost::asio::executor > strand_
Definition PeerImp.h:96
waitable_timer timer_
Definition PeerImp.h:97
clock_type::time_point lastPingTime_
Definition PeerImp.h:131
boost::circular_buffer< uint256 > recentLedgers_
Definition PeerImp.h:126
int getScore(bool haveItem) const override
Definition PeerImp.cpp:3664
std::string name_
Definition PeerImp.h:116
bool hasTxSet(uint256 const &hash) const override
Definition PeerImp.cpp:579
http_response_type response_
Definition PeerImp.h:194
boost::circular_buffer< uint256 > recentTxSets_
Definition PeerImp.h:127
clock_type::time_point trackingTime_
Definition PeerImp.h:112
beast::Journal const journal_
Definition PeerImp.h:91
std::string fingerprint_
Definition PeerImp.h:87
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition PeerImp.h:834
bool isHighLatency() const override
Definition PeerImp.cpp:3706
void cancelTimer() noexcept
Definition PeerImp.cpp:679
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition PeerImp.cpp:596
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition PeerImp.cpp:3399
uint256 previousLedgerHash_
Definition PeerImp.h:124
std::optional< std::uint32_t > lastPingSeq_
Definition PeerImp.h:130
void onWriteMessage(error_code ec, std::size_t bytesTransferred)
Definition PeerImp.cpp:989
bool detaching_
Definition PeerImp.h:113
boost::beast::ssl_stream< middle_type > stream_type
Definition PeerImp.h:79
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition PeerImp.cpp:404
void stop() override
Definition PeerImp.cpp:263
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
Definition PeerImp.cpp:2226
resource::Charge currentFeeCharge() const
Read-only accessor for the accumulated peer-message charge.
Definition PeerImp.h:763
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:378
std::string const & prefix() const
Definition PeerImp.h:579
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
Definition PeerImp.cpp:2954
void doAccept()
Definition PeerImp.cpp:788
std::shared_ptr< peer_finder::Slot > const & slot()
Definition PeerImp.h:296
void onReadMessage(error_code ec, std::size_t bytesTransferred)
Definition PeerImp.cpp:917
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition PeerImp.h:202
std::atomic< bool > chargeDisconnectFired_
Definition PeerImp.h:190
json::Value json() override
Definition PeerImp.cpp:427
std::mutex recentLock_
Definition PeerImp.h:181
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition PeerImp.cpp:556
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition PeerImp.h:82
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition PeerImp.cpp:1087
Represents a peer connection in the overlay.
std::uint32_t id_t
Uniquely identifies a peer.
A public key.
Definition PublicKey.h:53
A peer's signed, proposed position for use in RCLConsensus.
Maintains squelching of relaying messages from validators.
Definition Squelch.h:19
A consumption charge.
Definition Charge.h:13
An endpoint that consumes resources.
Definition Consumer.h:20
T is_same_v
T make_shared(T... args)
STL namespace.
Charge const kFeeTrivialPeer
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr std::size_t maximumManifestsMessageSize(std::size_t const trustedCount, std::size_t const untrustedCount)
Upper bound on the wire size of a TMManifests message.
Definition Message.h:48
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:370
std::unordered_set< Value, Hash, Pred, Allocator > hash_set
static constexpr char kFeatureLedgerReplay[]
Definition Handshake.h:131
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:651
static constexpr char kFeatureTxrr[]
Definition Handshake.h:129
HashRouterFlags
Definition HashRouter.h:20
constexpr std::size_t trustedManifestCount(std::optional< std::size_t > const &configured)
Number of trusted manifests allowed in a Manifest message.
Definition Manifest.h:261
std::unordered_map< Key, Value, Hash, Pred, Allocator > hash_map
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:262
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:182
std::pair< std::uint16_t, std::uint16_t > ProtocolVersion
Represents a particular version of the peer-to-peer protocol.
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition Handoff.h:12
constexpr std::size_t untrustedManifestCount(std::optional< std::size_t > const &configured)
Number of untrusted manifests to store in cache and allowed in one Manifest message.
Definition Manifest.h:246
static constexpr char kFeatureCompr[]
Definition Handshake.h:125
BaseUInt< 256 > uint256
Definition base_uint.h:580
static constexpr char kFeatureVprr[]
Definition Handshake.h:127
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
Definition Handoff.h:14
void update(resource::Charge f, std::string const &add)
Definition PeerImp.h:169
Used to represent the information stored in the blobs_v2 Json array.
Describes a connectable peer address along with some metadata.