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/overlay/Squelch.h>
26#include <xrpld/overlay/detail/OverlayImpl.h>
27#include <xrpld/overlay/detail/ProtocolMessage.h>
28#include <xrpld/overlay/detail/ProtocolVersion.h>
29#include <xrpld/peerfinder/PeerfinderManager.h>
30#include <xrpl/basics/Log.h>
31#include <xrpl/basics/RangeSet.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#include <cstdint>
43#include <optional>
44#include <queue>
45
46namespace ripple {
47
48struct ValidatorBlobInfo;
49class SHAMap;
50
51class PeerImp : public Peer,
52 public std::enable_shared_from_this<PeerImp>,
54{
55public:
58
59private:
61 using error_code = boost::system::error_code;
62 using socket_type = boost::asio::ip::tcp::socket;
63 using middle_type = boost::beast::tcp_stream;
64 using stream_type = boost::beast::ssl_stream<middle_type>;
65 using address_type = boost::asio::ip::address;
66 using endpoint_type = boost::asio::ip::tcp::endpoint;
68 boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
70
72 id_t const id_;
80 boost::asio::strand<boost::asio::executor> strand_;
82
83 // Updated at each stage of the connection process to reflect
84 // the current conditions as closely as possible.
86
87 // These are up here to prevent warnings about order of initializations
88 //
90 bool const inbound_;
91
92 // Protocol version to use for this link
94
96 clock_type::time_point trackingTime_;
97 bool detaching_ = false;
98 // Node public key of peer.
101 boost::shared_mutex mutable nameMutex_;
102
103 // The indices of the smallest and largest ledgers this peer has available
104 //
109
110 boost::circular_buffer<uint256> recentLedgers_{128};
111 boost::circular_buffer<uint256> recentTxSets_{128};
112
115 clock_type::time_point lastPingTime_;
116 clock_type::time_point const creationTime_;
117
120
121 // Notes on thread locking:
122 //
123 // During an audit it was noted that some member variables that looked
124 // like they need thread protection were not receiving it. And, indeed,
125 // that was correct. But the multi-phase initialization of PeerImp
126 // makes such an audit difficult. A further audit suggests that the
127 // locking is now protecting variables that don't need it. We're
128 // leaving that locking in place (for now) as a form of future proofing.
129 //
130 // Here are the variables that appear to need locking currently:
131 //
132 // o closedLedgerHash_
133 // o previousLedgerHash_
134 // o minLedger_
135 // o maxLedger_
136 // o recentLedgers_
137 // o recentTxSets_
138 // o trackingTime_
139 // o latency_
140 //
141 // The following variables are being protected preemptively:
142 //
143 // o name_
144 // o last_status_
145 //
146 // June 2019
147
149 {
152
153 void
155 {
156 XRPL_ASSERT(
157 f >= fee, "ripple::PeerImp::ChargeWithContext fee increases");
158 fee = f;
159 if (!context.empty())
160 {
161 context += " ";
162 }
163 context += add;
164 }
165 };
166
168 protocol::TMStatusChange last_status_;
172 boost::beast::multi_buffer read_buffer_;
175 boost::beast::http::fields const& headers_;
177 bool gracefulClose_ = false;
180 // The highest sequence of each PublisherList that has
181 // been sent to or received from this peer.
183
185
186 // Queue of transactions' hashes that have not been
187 // relayed. The hashes are sent once a second to a peer
188 // and the peer requests missing transactions from the node.
190 // true if tx reduce-relay feature is enabled on the peer.
192 // true if validation/proposal reduce-relay feature is enabled
193 // on the peer.
197
198 friend class OverlayImpl;
199
201 {
202 public:
203 Metrics() = default;
204 Metrics(Metrics const&) = delete;
205 Metrics&
206 operator=(Metrics const&) = delete;
207 Metrics(Metrics&&) = delete;
208 Metrics&
209 operator=(Metrics&&) = delete;
210
211 void
214 average_bytes() const;
216 total_bytes() const;
217
218 private:
219 boost::shared_mutex mutable mutex_;
220 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
221 clock_type::time_point intervalStart_{clock_type::now()};
225 };
226
227 struct
228 {
232
233public:
234 PeerImp(PeerImp const&) = delete;
235 PeerImp&
236 operator=(PeerImp const&) = delete;
237
239 PeerImp(
240 Application& app,
241 id_t id,
243 http_request_type&& request,
244 PublicKey const& publicKey,
246 Resource::Consumer consumer,
247 std::unique_ptr<stream_type>&& stream_ptr,
248 OverlayImpl& overlay);
249
251 // VFALCO legacyPublicKey should be implied by the Slot
252 template <class Buffers>
253 PeerImp(
254 Application& app,
255 std::unique_ptr<stream_type>&& stream_ptr,
256 Buffers const& buffers,
258 http_response_type&& response,
259 Resource::Consumer usage,
260 PublicKey const& publicKey,
262 id_t id,
263 OverlayImpl& overlay);
264
265 virtual ~PeerImp();
266
267 beast::Journal const&
268 pjournal() const
269 {
270 return p_journal_;
271 }
272
275 {
276 return slot_;
277 }
278
279 // Work-around for calling shared_from_this in constructors
280 virtual void
281 run();
282
283 // Called when Overlay gets a stop request.
284 void
285 stop() override;
286
287 //
288 // Network
289 //
290
291 void
292 send(std::shared_ptr<Message> const& m) override;
293
295 void
296 sendTxQueue() override;
297
301 void
302 addTxQueue(uint256 const& hash) override;
303
307 void
308 removeTxQueue(uint256 const& hash) override;
309
311 template <
312 class FwdIt,
313 class = typename std::enable_if_t<std::is_same<
315 PeerFinder::Endpoint>::value>>
316 void
317 sendEndpoints(FwdIt first, FwdIt last);
318
320 getRemoteAddress() const override
321 {
322 return remote_address_;
323 }
324
325 void
326 charge(Resource::Charge const& fee, std::string const& context) override;
327
328 //
329 // Identity
330 //
331
333 id() const override
334 {
335 return id_;
336 }
337
339 bool
340 crawl() const;
341
342 bool
343 cluster() const override;
344
348 void
349 checkTracking(std::uint32_t validationSeq);
350
351 void
353
354 PublicKey const&
355 getNodePublic() const override
356 {
357 return publicKey_;
358 }
359
362 getVersion() const;
363
364 // Return the connection elapsed time.
365 clock_type::duration
366 uptime() const
367 {
369 }
370
372 json() override;
373
374 bool
375 supportsFeature(ProtocolFeature f) const override;
376
378 publisherListSequence(PublicKey const& pubKey) const override
379 {
381
382 auto iter = publisherListSequences_.find(pubKey);
383 if (iter != publisherListSequences_.end())
384 return iter->second;
385 return {};
386 }
387
388 void
390 override
391 {
393
394 publisherListSequences_[pubKey] = seq;
395 }
396
397 //
398 // Ledger
399 //
400
401 uint256 const&
402 getClosedLedgerHash() const override
403 {
404 return closedLedgerHash_;
405 }
406
407 bool
408 hasLedger(uint256 const& hash, std::uint32_t seq) const override;
409
410 void
411 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
412
413 bool
414 hasTxSet(uint256 const& hash) const override;
415
416 void
417 cycleStatus() override;
418
419 bool
420 hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
421
422 // Called to determine our priority for querying
423 int
424 getScore(bool haveItem) const override;
425
426 bool
427 isHighLatency() const override;
428
429 void
430 fail(std::string const& reason);
431
432 bool
433 compressionEnabled() const override
434 {
435 return compressionEnabled_ == Compressed::On;
436 }
437
438 bool
439 txReduceRelayEnabled() const override
440 {
442 }
443
444private:
445 void
446 close();
447
448 void
449 fail(std::string const& name, error_code ec);
450
451 void
453
454 void
455 setTimer();
456
457 void
458 cancelTimer();
459
460 static std::string
461 makePrefix(id_t id);
462
463 // Called when the timer wait completes
464 void
465 onTimer(boost::system::error_code const& ec);
466
467 // Called when SSL shutdown completes
468 void
470
471 void
472 doAccept();
473
475 name() const;
476
478 domain() const;
479
480 //
481 // protocol message loop
482 //
483
484 // Starts the protocol message loop
485 void
487
488 // Called when protocol message bytes are received
489 void
490 onReadMessage(error_code ec, std::size_t bytes_transferred);
491
492 // Called when protocol messages bytes are sent
493 void
494 onWriteMessage(error_code ec, std::size_t bytes_transferred);
495
508 void
511 bool eraseTxQueue,
512 bool batch);
513
519 void
522
523 // Check if reduce-relay feature is enabled and
524 // reduce_relay::WAIT_ON_BOOTUP time passed since the start
525 bool
527
528public:
529 //--------------------------------------------------------------------------
530 //
531 // ProtocolStream
532 //
533 //--------------------------------------------------------------------------
534
535 void
537
538 void
540 std::uint16_t type,
542 std::size_t size,
543 std::size_t uncompressed_size,
544 bool isCompressed);
545
546 void
548 std::uint16_t type,
550
551 void
553 void
555 void
557 void
559 void
561 void
563 void
565 void
567 void
569 void
571 void
573 void
575 void
577 void
579 void
581 void
583 void
585 void
587 void
589 void
591 void
593
594private:
595 //--------------------------------------------------------------------------
596 // lockedRecentLock is passed as a reminder to callers that recentLock_
597 // must be locked.
598 void
599 addLedger(
600 uint256 const& hash,
601 std::lock_guard<std::mutex> const& lockedRecentLock);
602
603 void
605
606 void
608 std::string const& messageType,
609 std::string const& manifest,
610 std::uint32_t version,
611 std::vector<ValidatorBlobInfo> const& blobs);
612
617 void
619
620 void
622 int flags,
623 bool checkSignature,
625 bool batch);
626
627 void
629 bool isTrusted,
631 RCLCxPeerPos peerPos);
632
633 void
636 uint256 const& key,
638
639 void
641 std::shared_ptr<Ledger const> const& ledger,
642 protocol::TMLedgerData& ledgerData);
643
646
649
650 void
652};
653
654//------------------------------------------------------------------------------
655
656template <class Buffers>
658 Application& app,
659 std::unique_ptr<stream_type>&& stream_ptr,
660 Buffers const& buffers,
662 http_response_type&& response,
663 Resource::Consumer usage,
664 PublicKey const& publicKey,
666 id_t id,
667 OverlayImpl& overlay)
668 : Child(overlay)
669 , app_(app)
670 , id_(id)
671 , sink_(app_.journal("Peer"), makePrefix(id))
672 , p_sink_(app_.journal("Protocol"), makePrefix(id))
673 , journal_(sink_)
674 , p_journal_(p_sink_)
675 , stream_ptr_(std::move(stream_ptr))
676 , socket_(stream_ptr_->next_layer().socket())
677 , stream_(*stream_ptr_)
678 , strand_(socket_.get_executor())
679 , timer_(waitable_timer{socket_.get_executor()})
680 , remote_address_(slot->remote_endpoint())
681 , overlay_(overlay)
682 , inbound_(false)
683 , protocol_(protocol)
684 , tracking_(Tracking::unknown)
685 , trackingTime_(clock_type::now())
686 , publicKey_(publicKey)
687 , lastPingTime_(clock_type::now())
688 , creationTime_(clock_type::now())
689 , squelch_(app_.journal("Squelch"))
690 , usage_(usage)
691 , fee_{Resource::feeTrivialPeer}
692 , slot_(std::move(slot))
693 , response_(std::move(response))
694 , headers_(response_)
695 , compressionEnabled_(
697 headers_,
699 "lz4",
700 app_.config().COMPRESSION)
701 ? Compressed::On
702 : Compressed::Off)
703 , txReduceRelayEnabled_(peerFeatureEnabled(
704 headers_,
706 app_.config().TX_REDUCE_RELAY_ENABLE))
707 , vpReduceRelayEnabled_(peerFeatureEnabled(
708 headers_,
710 app_.config().VP_REDUCE_RELAY_ENABLE))
711 , ledgerReplayEnabled_(peerFeatureEnabled(
712 headers_,
714 app_.config().LEDGER_REPLAY))
715 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
716{
717 read_buffer_.commit(boost::asio::buffer_copy(
718 read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
719 JLOG(journal_.info()) << "compression enabled "
720 << (compressionEnabled_ == Compressed::On)
721 << " vp reduce-relay enabled "
723 << " tx reduce-relay enabled "
725 << " " << id_;
726}
727
728template <class FwdIt, class>
729void
730PeerImp::sendEndpoints(FwdIt first, FwdIt last)
731{
732 protocol::TMEndpoints tm;
733
734 while (first != last)
735 {
736 auto& tme2(*tm.add_endpoints_v2());
737 tme2.set_endpoint(first->address.to_string());
738 tme2.set_hops(first->hops);
739 first++;
740 }
741 tm.set_version(2);
742
743 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
744}
745
746} // namespace ripple
747
748#endif
Represents a JSON value.
Definition: json_value.h:147
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
A generic endpoint for log messages.
Definition: Journal.h:59
Stream info() const
Definition: Journal.h:323
Wraps a Journal::Sink to prefix its output with a string.
Definition: WrappedSink.h:34
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition: PeerImp.h:220
std::uint64_t accumBytes_
Definition: PeerImp.h:223
Metrics & operator=(Metrics const &)=delete
Metrics(Metrics &&)=delete
std::uint64_t total_bytes() const
Definition: PeerImp.cpp:3487
std::uint64_t totalBytes_
Definition: PeerImp.h:222
Metrics & operator=(Metrics &&)=delete
std::uint64_t average_bytes() const
Definition: PeerImp.cpp:3480
void add_message(std::uint64_t bytes)
Definition: PeerImp.cpp:3454
Metrics(Metrics const &)=delete
boost::shared_mutex mutex_
Definition: PeerImp.h:219
std::uint64_t rollingAvgBytes_
Definition: PeerImp.h:224
clock_type::time_point intervalStart_
Definition: PeerImp.h:221
std::queue< std::shared_ptr< Message > > send_queue_
Definition: PeerImp.h:176
bool vpReduceRelayEnabled_
Definition: PeerImp.h:194
boost::beast::ssl_stream< middle_type > stream_type
Definition: PeerImp.h:64
PeerImp & operator=(PeerImp const &)=delete
std::unique_ptr< LoadEvent > load_event_
Definition: PeerImp.h:179
boost::beast::http::fields const & headers_
Definition: PeerImp.h:175
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
Definition: PeerImp.cpp:1986
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition: PeerImp.cpp:1040
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition: PeerImp.cpp:514
Metrics sent
Definition: PeerImp.h:229
clock_type::duration uptime() const
Definition: PeerImp.h:366
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition: PeerImp.cpp:330
protocol::TMStatusChange last_status_
Definition: PeerImp.h:168
boost::shared_mutex nameMutex_
Definition: PeerImp.h:101
std::string name_
Definition: PeerImp.h:100
boost::circular_buffer< uint256 > recentTxSets_
Definition: PeerImp.h:111
std::unique_ptr< stream_type > stream_ptr_
Definition: PeerImp.h:77
void checkTransaction(int flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
Definition: PeerImp.cpp:2791
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition: PeerImp.cpp:1049
bool detaching_
Definition: PeerImp.h:97
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition: PeerImp.h:57
Compressed compressionEnabled_
Definition: PeerImp.h:184
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition: PeerImp.h:378
uint256 closedLedgerHash_
Definition: PeerImp.h:107
std::string domain() const
Definition: PeerImp.cpp:832
std::optional< std::uint32_t > lastPingSeq_
Definition: PeerImp.h:114
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition: PeerImp.h:274
void onTimer(boost::system::error_code const &ec)
Definition: PeerImp.cpp:680
bool gracefulClose_
Definition: PeerImp.h:177
http_response_type response_
Definition: PeerImp.h:174
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition: PeerImp.h:730
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition: PeerImp.cpp:3049
boost::asio::ip::tcp::endpoint endpoint_type
Definition: PeerImp.h:66
beast::Journal const journal_
Definition: PeerImp.h:75
virtual void run()
Definition: PeerImp.cpp:156
boost::asio::ip::address address_type
Definition: PeerImp.h:65
void gracefulClose()
Definition: PeerImp.cpp:624
LedgerIndex maxLedger_
Definition: PeerImp.h:106
beast::Journal const p_journal_
Definition: PeerImp.h:76
void cancelTimer()
Definition: PeerImp.cpp:663
bool const inbound_
Definition: PeerImp.h:90
PeerImp(PeerImp const &)=delete
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3220
Application & app_
Definition: PeerImp.h:71
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition: PeerImp.cpp:3185
void stop() override
Definition: PeerImp.cpp:214
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition: PeerImp.cpp:556
bool hasTxSet(uint256 const &hash) const override
Definition: PeerImp.cpp:538
clock_type::time_point lastPingTime_
Definition: PeerImp.h:115
void onMessageUnknown(std::uint16_t type)
Definition: PeerImp.cpp:1000
std::shared_ptr< PeerFinder::Slot > const slot_
Definition: PeerImp.h:171
boost::circular_buffer< uint256 > recentLedgers_
Definition: PeerImp.h:110
id_t const id_
Definition: PeerImp.h:72
std::optional< std::chrono::milliseconds > latency_
Definition: PeerImp.h:113
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
Called from onMessage(TMTransaction(s)).
Definition: PeerImp.cpp:1241
beast::IP::Endpoint const remote_address_
Definition: PeerImp.h:85
boost::asio::ip::tcp::socket socket_type
Definition: PeerImp.h:62
Json::Value json() override
Definition: PeerImp.cpp:379
PublicKey const publicKey_
Definition: PeerImp.h:99
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition: PeerImp.cpp:2686
hash_set< uint256 > txQueue_
Definition: PeerImp.h:189
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3089
std::mutex recentLock_
Definition: PeerImp.h:167
void doAccept()
Definition: PeerImp.cpp:757
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:1006
bool txReduceRelayEnabled_
Definition: PeerImp.h:191
beast::IP::Endpoint getRemoteAddress() const override
Definition: PeerImp.h:320
Metrics recv
Definition: PeerImp.h:230
bool reduceRelayReady()
Definition: PeerImp.cpp:3444
clock_type::time_point trackingTime_
Definition: PeerImp.h:96
socket_type & socket_
Definition: PeerImp.h:78
ProtocolVersion protocol_
Definition: PeerImp.h:93
clock_type::time_point const creationTime_
Definition: PeerImp.h:116
reduce_relay::Squelch< UptimeClock > squelch_
Definition: PeerImp.h:118
hash_map< PublicKey, std::size_t > publisherListSequences_
Definition: PeerImp.h:182
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition: PeerImp.cpp:371
struct ripple::PeerImp::@22 metrics_
uint256 previousLedgerHash_
Definition: PeerImp.h:108
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
void setTimer()
Definition: PeerImp.cpp:645
boost::beast::tcp_stream middle_type
Definition: PeerImp.h:63
int getScore(bool haveItem) const override
Definition: PeerImp.cpp:3399
void send(std::shared_ptr< Message > const &m) override
Definition: PeerImp.cpp:240
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
Definition: PeerImp.cpp:2736
static std::string makePrefix(id_t id)
Definition: PeerImp.cpp:672
std::string name() const
Definition: PeerImp.cpp:825
boost::system::error_code error_code
Definition: PeerImp.h:61
void doFetchPack(const std::shared_ptr< protocol::TMGetObjectByHash > &packet)
Definition: PeerImp.cpp:2702
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:880
bool ledgerReplayEnabled_
Definition: PeerImp.h:195
beast::WrappedSink p_sink_
Definition: PeerImp.h:74
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition: PeerImp.h:68
PublicKey const & getNodePublic() const override
Definition: PeerImp.h:355
static std::atomic_bool reduceRelayReady_
Definition: PeerImp.h:119
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition: PeerImp.cpp:356
waitable_timer timer_
Definition: PeerImp.h:81
beast::Journal const & pjournal() const
Definition: PeerImp.h:268
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition: PeerImp.cpp:294
bool compressionEnabled() const override
Definition: PeerImp.h:433
bool txReduceRelayEnabled() const override
Definition: PeerImp.h:439
bool supportsFeature(ProtocolFeature f) const override
Definition: PeerImp.cpp:497
uint256 const & getClosedLedgerHash() const override
Definition: PeerImp.h:402
beast::WrappedSink sink_
Definition: PeerImp.h:73
ChargeWithContext fee_
Definition: PeerImp.h:170
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:944
http_request_type request_
Definition: PeerImp.h:173
OverlayImpl & overlay_
Definition: PeerImp.h:89
LedgerIndex minLedger_
Definition: PeerImp.h:105
virtual ~PeerImp()
Definition: PeerImp.cpp:133
Peer::id_t id() const override
Definition: PeerImp.h:333
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition: PeerImp.h:196
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:2556
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition: PeerImp.cpp:313
int large_sendq_
Definition: PeerImp.h:178
stream_type & stream_
Definition: PeerImp.h:79
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition: PeerImp.cpp:365
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition: PeerImp.cpp:2909
bool isHighLatency() const override
Definition: PeerImp.cpp:3437
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition: PeerImp.cpp:1919
void onShutdown(error_code ec)
Definition: PeerImp.cpp:741
boost::asio::strand< boost::asio::executor > strand_
Definition: PeerImp.h:80
void cycleStatus() override
Definition: PeerImp.cpp:546
boost::beast::multi_buffer read_buffer_
Definition: PeerImp.h:172
Resource::Consumer usage_
Definition: PeerImp.h:169
void checkValidation(std::shared_ptr< STValidation > const &val, uint256 const &key, std::shared_ptr< protocol::TMValidation > const &packet)
Definition: PeerImp.cpp:2952
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition: PeerImp.h:389
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition: PeerImp.cpp:529
void doProtocolStart()
Definition: PeerImp.cpp:842
void fail(std::string const &reason)
Definition: PeerImp.cpp:590
std::atomic< Tracking > tracking_
Definition: PeerImp.h:95
Represents a peer connection in the overlay.
std::uint32_t id_t
Uniquely identifies a peer.
A public key.
Definition: PublicKey.h:62
A peer's signed, proposed position for use in RCLConsensus.
Definition: RCLCxPeerPos.h:44
A consumption charge.
Definition: Charge.h:31
An endpoint that consumes resources.
Definition: Consumer.h:35
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:26
boost::beast::http::response< boost::beast::http::dynamic_body > http_response_type
Definition: Handoff.h:34
static constexpr char FEATURE_COMPR[]
Definition: Handshake.h:142
static constexpr char FEATURE_LEDGER_REPLAY[]
Definition: Handshake.h:148
boost::beast::http::request< boost::beast::http::dynamic_body > http_request_type
Definition: Handoff.h:31
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:199
static constexpr char FEATURE_TXRR[]
Definition: Handshake.h:146
@ manifest
Manifest.
static constexpr char FEATURE_VPRR[]
Definition: Handshake.h:144
STL namespace.
Describes a connectible peer address along with some metadata.
void update(Resource::Charge f, std::string const &add)
Definition: PeerImp.h:154