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/ProtocolVersion.h>
28#include <xrpld/peerfinder/PeerfinderManager.h>
29
30#include <xrpl/basics/Log.h>
31#include <xrpl/basics/UnorderedContainers.h>
32#include <xrpl/beast/utility/WrappedSink.h>
33#include <xrpl/protocol/Protocol.h>
34#include <xrpl/protocol/STTx.h>
35#include <xrpl/protocol/STValidation.h>
36#include <xrpl/resource/Fees.h>
37
38#include <boost/circular_buffer.hpp>
39#include <boost/endian/conversion.hpp>
40#include <boost/thread/shared_mutex.hpp>
41
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,
158 "ripple::PeerImp::ChargeWithContext::update : fee increases");
159 fee = f;
160 if (!context.empty())
161 {
162 context += " ";
163 }
164 context += add;
165 }
166 };
167
169 protocol::TMStatusChange last_status_;
173 boost::beast::multi_buffer read_buffer_;
176 boost::beast::http::fields const& headers_;
178 bool gracefulClose_ = false;
181 // The highest sequence of each PublisherList that has
182 // been sent to or received from this peer.
184
186
187 // Queue of transactions' hashes that have not been
188 // relayed. The hashes are sent once a second to a peer
189 // and the peer requests missing transactions from the node.
191 // true if tx reduce-relay feature is enabled on the peer.
193 // true if validation/proposal reduce-relay feature is enabled
194 // on the peer.
198
199 friend class OverlayImpl;
200
202 {
203 public:
204 Metrics() = default;
205 Metrics(Metrics const&) = delete;
206 Metrics&
207 operator=(Metrics const&) = delete;
208 Metrics(Metrics&&) = delete;
209 Metrics&
210 operator=(Metrics&&) = delete;
211
212 void
215 average_bytes() const;
217 total_bytes() const;
218
219 private:
220 boost::shared_mutex mutable mutex_;
221 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
222 clock_type::time_point intervalStart_{clock_type::now()};
226 };
227
228 struct
229 {
233
234public:
235 PeerImp(PeerImp const&) = delete;
236 PeerImp&
237 operator=(PeerImp const&) = delete;
238
240 PeerImp(
241 Application& app,
242 id_t id,
244 http_request_type&& request,
245 PublicKey const& publicKey,
247 Resource::Consumer consumer,
248 std::unique_ptr<stream_type>&& stream_ptr,
249 OverlayImpl& overlay);
250
252 // VFALCO legacyPublicKey should be implied by the Slot
253 template <class Buffers>
254 PeerImp(
255 Application& app,
256 std::unique_ptr<stream_type>&& stream_ptr,
257 Buffers const& buffers,
259 http_response_type&& response,
260 Resource::Consumer usage,
261 PublicKey const& publicKey,
263 id_t id,
264 OverlayImpl& overlay);
265
266 virtual ~PeerImp();
267
268 beast::Journal const&
269 pjournal() const
270 {
271 return p_journal_;
272 }
273
276 {
277 return slot_;
278 }
279
280 // Work-around for calling shared_from_this in constructors
281 virtual void
282 run();
283
284 // Called when Overlay gets a stop request.
285 void
286 stop() override;
287
288 //
289 // Network
290 //
291
292 void
293 send(std::shared_ptr<Message> const& m) override;
294
296 void
297 sendTxQueue() override;
298
302 void
303 addTxQueue(uint256 const& hash) override;
304
308 void
309 removeTxQueue(uint256 const& hash) override;
310
312 template <
313 class FwdIt,
314 class = typename std::enable_if_t<std::is_same<
316 PeerFinder::Endpoint>::value>>
317 void
318 sendEndpoints(FwdIt first, FwdIt last);
319
321 getRemoteAddress() const override
322 {
323 return remote_address_;
324 }
325
326 void
327 charge(Resource::Charge const& fee, std::string const& context) override;
328
329 //
330 // Identity
331 //
332
334 id() const override
335 {
336 return id_;
337 }
338
340 bool
341 crawl() const;
342
343 bool
344 cluster() const override;
345
349 void
350 checkTracking(std::uint32_t validationSeq);
351
352 void
354
355 PublicKey const&
356 getNodePublic() const override
357 {
358 return publicKey_;
359 }
360
363 getVersion() const;
364
365 // Return the connection elapsed time.
366 clock_type::duration
367 uptime() const
368 {
370 }
371
373 json() override;
374
375 bool
376 supportsFeature(ProtocolFeature f) const override;
377
379 publisherListSequence(PublicKey const& pubKey) const override
380 {
382
383 auto iter = publisherListSequences_.find(pubKey);
384 if (iter != publisherListSequences_.end())
385 return iter->second;
386 return {};
387 }
388
389 void
391 override
392 {
394
396 }
397
398 //
399 // Ledger
400 //
401
402 uint256 const&
403 getClosedLedgerHash() const override
404 {
405 return closedLedgerHash_;
406 }
407
408 bool
409 hasLedger(uint256 const& hash, std::uint32_t seq) const override;
410
411 void
412 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
413
414 bool
415 hasTxSet(uint256 const& hash) const override;
416
417 void
418 cycleStatus() override;
419
420 bool
421 hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
422
423 // Called to determine our priority for querying
424 int
425 getScore(bool haveItem) const override;
426
427 bool
428 isHighLatency() const override;
429
430 void
431 fail(std::string const& reason);
432
433 bool
434 compressionEnabled() const override
435 {
436 return compressionEnabled_ == Compressed::On;
437 }
438
439 bool
440 txReduceRelayEnabled() const override
441 {
443 }
444
445private:
446 void
447 close();
448
449 void
450 fail(std::string const& name, error_code ec);
451
452 void
454
455 void
456 setTimer();
457
458 void
459 cancelTimer();
460
461 static std::string
462 makePrefix(id_t id);
463
464 // Called when the timer wait completes
465 void
466 onTimer(boost::system::error_code const& ec);
467
468 // Called when SSL shutdown completes
469 void
471
472 void
473 doAccept();
474
476 name() const;
477
479 domain() const;
480
481 //
482 // protocol message loop
483 //
484
485 // Starts the protocol message loop
486 void
488
489 // Called when protocol message bytes are received
490 void
491 onReadMessage(error_code ec, std::size_t bytes_transferred);
492
493 // Called when protocol messages bytes are sent
494 void
495 onWriteMessage(error_code ec, std::size_t bytes_transferred);
496
509 void
512 bool eraseTxQueue,
513 bool batch);
514
520 void
523
524 // Check if reduce-relay feature is enabled and
525 // reduce_relay::WAIT_ON_BOOTUP time passed since the start
526 bool
528
529public:
530 //--------------------------------------------------------------------------
531 //
532 // ProtocolStream
533 //
534 //--------------------------------------------------------------------------
535
536 void
538
539 void
541 std::uint16_t type,
543 std::size_t size,
544 std::size_t uncompressed_size,
545 bool isCompressed);
546
547 void
549 std::uint16_t type,
551
552 void
554 void
556 void
558 void
560 void
562 void
564 void
566 void
568 void
570 void
572 void
574 void
576 void
578 void
580 void
582 void
584 void
586 void
588 void
590 void
592 void
594
595private:
596 //--------------------------------------------------------------------------
597 // lockedRecentLock is passed as a reminder to callers that recentLock_
598 // must be locked.
599 void
600 addLedger(
601 uint256 const& hash,
602 std::lock_guard<std::mutex> const& lockedRecentLock);
603
604 void
606
607 void
609 std::string const& messageType,
610 std::string const& manifest,
611 std::uint32_t version,
612 std::vector<ValidatorBlobInfo> const& blobs);
613
618 void
620
621 void
623 int flags,
624 bool checkSignature,
626 bool batch);
627
628 void
630 bool isTrusted,
632 RCLCxPeerPos peerPos);
633
634 void
637 uint256 const& key,
639
640 void
642 std::shared_ptr<Ledger const> const& ledger,
643 protocol::TMLedgerData& ledgerData);
644
647
650
651 void
653};
654
655//------------------------------------------------------------------------------
656
657template <class Buffers>
659 Application& app,
660 std::unique_ptr<stream_type>&& stream_ptr,
661 Buffers const& buffers,
663 http_response_type&& response,
664 Resource::Consumer usage,
665 PublicKey const& publicKey,
667 id_t id,
668 OverlayImpl& overlay)
669 : Child(overlay)
670 , app_(app)
671 , id_(id)
672 , sink_(app_.journal("Peer"), makePrefix(id))
673 , p_sink_(app_.journal("Protocol"), makePrefix(id))
674 , journal_(sink_)
675 , p_journal_(p_sink_)
676 , stream_ptr_(std::move(stream_ptr))
677 , socket_(stream_ptr_->next_layer().socket())
678 , stream_(*stream_ptr_)
679 , strand_(socket_.get_executor())
680 , timer_(waitable_timer{socket_.get_executor()})
681 , remote_address_(slot->remote_endpoint())
682 , overlay_(overlay)
683 , inbound_(false)
684 , protocol_(protocol)
685 , tracking_(Tracking::unknown)
686 , trackingTime_(clock_type::now())
687 , publicKey_(publicKey)
688 , lastPingTime_(clock_type::now())
689 , creationTime_(clock_type::now())
690 , squelch_(app_.journal("Squelch"))
691 , usage_(usage)
692 , fee_{Resource::feeTrivialPeer}
693 , slot_(std::move(slot))
694 , response_(std::move(response))
695 , headers_(response_)
696 , compressionEnabled_(
698 headers_,
700 "lz4",
701 app_.config().COMPRESSION)
702 ? Compressed::On
703 : Compressed::Off)
704 , txReduceRelayEnabled_(peerFeatureEnabled(
705 headers_,
707 app_.config().TX_REDUCE_RELAY_ENABLE))
708 , vpReduceRelayEnabled_(app_.config().VP_REDUCE_RELAY_ENABLE)
709 , ledgerReplayEnabled_(peerFeatureEnabled(
710 headers_,
712 app_.config().LEDGER_REPLAY))
713 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
714{
715 read_buffer_.commit(boost::asio::buffer_copy(
716 read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
717 JLOG(journal_.info()) << "compression enabled "
718 << (compressionEnabled_ == Compressed::On)
719 << " vp reduce-relay enabled "
721 << " tx reduce-relay enabled "
723 << " " << id_;
724}
725
726template <class FwdIt, class>
727void
728PeerImp::sendEndpoints(FwdIt first, FwdIt last)
729{
730 protocol::TMEndpoints tm;
731
732 while (first != last)
733 {
734 auto& tme2(*tm.add_endpoints_v2());
735 tme2.set_endpoint(first->address.to_string());
736 tme2.set_hops(first->hops);
737 first++;
738 }
739 tm.set_version(2);
740
741 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
742}
743
744} // namespace ripple
745
746#endif
Represents a JSON value.
Definition: json_value.h:150
A version-independent IP address and port combination.
Definition: IPEndpoint.h:39
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
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition: PeerImp.h:221
std::uint64_t accumBytes_
Definition: PeerImp.h:224
Metrics & operator=(Metrics const &)=delete
Metrics(Metrics &&)=delete
std::uint64_t total_bytes() const
Definition: PeerImp.cpp:3528
std::uint64_t totalBytes_
Definition: PeerImp.h:223
Metrics & operator=(Metrics &&)=delete
std::uint64_t average_bytes() const
Definition: PeerImp.cpp:3521
void add_message(std::uint64_t bytes)
Definition: PeerImp.cpp:3495
Metrics(Metrics const &)=delete
boost::shared_mutex mutex_
Definition: PeerImp.h:220
std::uint64_t rollingAvgBytes_
Definition: PeerImp.h:225
clock_type::time_point intervalStart_
Definition: PeerImp.h:222
std::queue< std::shared_ptr< Message > > send_queue_
Definition: PeerImp.h:177
bool vpReduceRelayEnabled_
Definition: PeerImp.h:195
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:180
boost::beast::http::fields const & headers_
Definition: PeerImp.h:176
void onValidatorListMessage(std::string const &messageType, std::string const &manifest, std::uint32_t version, std::vector< ValidatorBlobInfo > const &blobs)
Definition: PeerImp.cpp:2022
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition: PeerImp.cpp:1057
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition: PeerImp.cpp:522
Metrics sent
Definition: PeerImp.h:230
clock_type::duration uptime() const
Definition: PeerImp.h:367
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition: PeerImp.cpp:338
protocol::TMStatusChange last_status_
Definition: PeerImp.h:169
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:2832
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition: PeerImp.cpp:1066
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:185
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition: PeerImp.h:379
uint256 closedLedgerHash_
Definition: PeerImp.h:107
std::string domain() const
Definition: PeerImp.cpp:840
std::optional< std::uint32_t > lastPingSeq_
Definition: PeerImp.h:114
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition: PeerImp.h:275
void onTimer(boost::system::error_code const &ec)
Definition: PeerImp.cpp:688
bool gracefulClose_
Definition: PeerImp.h:178
http_response_type response_
Definition: PeerImp.h:175
void sendEndpoints(FwdIt first, FwdIt last)
Send a set of PeerFinder endpoints as a protocol message.
Definition: PeerImp.h:728
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition: PeerImp.cpp:3090
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Definition: PeerImp.cpp:2743
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:154
boost::asio::ip::address address_type
Definition: PeerImp.h:65
struct ripple::PeerImp::@21 metrics_
void gracefulClose()
Definition: PeerImp.cpp:632
LedgerIndex maxLedger_
Definition: PeerImp.h:106
beast::Journal const p_journal_
Definition: PeerImp.h:76
void cancelTimer()
Definition: PeerImp.cpp:671
bool const inbound_
Definition: PeerImp.h:90
PeerImp(PeerImp const &)=delete
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3261
Application & app_
Definition: PeerImp.h:71
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition: PeerImp.cpp:3226
void stop() override
Definition: PeerImp.cpp:212
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition: PeerImp.cpp:564
bool hasTxSet(uint256 const &hash) const override
Definition: PeerImp.cpp:546
clock_type::time_point lastPingTime_
Definition: PeerImp.h:115
void onMessageUnknown(std::uint16_t type)
Definition: PeerImp.cpp:1008
std::shared_ptr< PeerFinder::Slot > const slot_
Definition: PeerImp.h:172
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:1258
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:387
PublicKey const publicKey_
Definition: PeerImp.h:99
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition: PeerImp.cpp:2727
hash_set< uint256 > txQueue_
Definition: PeerImp.h:190
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3130
std::mutex recentLock_
Definition: PeerImp.h:168
void doAccept()
Definition: PeerImp.cpp:765
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:1014
bool txReduceRelayEnabled_
Definition: PeerImp.h:192
beast::IP::Endpoint getRemoteAddress() const override
Definition: PeerImp.h:321
Metrics recv
Definition: PeerImp.h:231
bool reduceRelayReady()
Definition: PeerImp.cpp:3485
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:183
std::string getVersion() const
Return the version of rippled that the peer is running, if reported.
Definition: PeerImp.cpp:379
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:350
void setTimer()
Definition: PeerImp.cpp:653
boost::beast::tcp_stream middle_type
Definition: PeerImp.h:63
int getScore(bool haveItem) const override
Definition: PeerImp.cpp:3440
void send(std::shared_ptr< Message > const &m) override
Definition: PeerImp.cpp:238
void doTransactions(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Process peer's request to send missing transactions.
Definition: PeerImp.cpp:2777
static std::string makePrefix(id_t id)
Definition: PeerImp.cpp:680
std::string name() const
Definition: PeerImp.cpp:833
boost::system::error_code error_code
Definition: PeerImp.h:61
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:888
bool ledgerReplayEnabled_
Definition: PeerImp.h:196
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:356
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:364
waitable_timer timer_
Definition: PeerImp.h:81
beast::Journal const & pjournal() const
Definition: PeerImp.h:269
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition: PeerImp.cpp:302
bool compressionEnabled() const override
Definition: PeerImp.h:434
bool txReduceRelayEnabled() const override
Definition: PeerImp.h:440
bool supportsFeature(ProtocolFeature f) const override
Definition: PeerImp.cpp:505
uint256 const & getClosedLedgerHash() const override
Definition: PeerImp.h:403
beast::WrappedSink sink_
Definition: PeerImp.h:73
ChargeWithContext fee_
Definition: PeerImp.h:171
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:952
http_request_type request_
Definition: PeerImp.h:174
OverlayImpl & overlay_
Definition: PeerImp.h:89
LedgerIndex minLedger_
Definition: PeerImp.h:105
virtual ~PeerImp()
Definition: PeerImp.cpp:131
Peer::id_t id() const override
Definition: PeerImp.h:334
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition: PeerImp.h:197
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:2607
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition: PeerImp.cpp:321
int large_sendq_
Definition: PeerImp.h:179
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:373
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition: PeerImp.cpp:2950
bool isHighLatency() const override
Definition: PeerImp.cpp:3478
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition: PeerImp.cpp:1955
void onShutdown(error_code ec)
Definition: PeerImp.cpp:749
boost::asio::strand< boost::asio::executor > strand_
Definition: PeerImp.h:80
void cycleStatus() override
Definition: PeerImp.cpp:554
boost::beast::multi_buffer read_buffer_
Definition: PeerImp.h:173
Resource::Consumer usage_
Definition: PeerImp.h:170
void checkValidation(std::shared_ptr< STValidation > const &val, uint256 const &key, std::shared_ptr< protocol::TMValidation > const &packet)
Definition: PeerImp.cpp:2993
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition: PeerImp.h:390
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition: PeerImp.cpp:537
void doProtocolStart()
Definition: PeerImp.cpp:850
void fail(std::string const &reason)
Definition: PeerImp.cpp:598
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
Set the fee on a JTx.
Definition: fee.h:37
Match set account flags.
Definition: flags.h:125
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:36
static constexpr char FEATURE_COMPR[]
Definition: Handshake.h:141
static constexpr char FEATURE_LEDGER_REPLAY[]
Definition: Handshake.h:147
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.
STL namespace.
Describes a connectible peer address along with some metadata.
void update(Resource::Charge f, std::string const &add)
Definition: PeerImp.h:154
Set the sequence number on a JTx.
Definition: seq.h:34