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 <cstdint>
44#include <optional>
45#include <queue>
46
47namespace ripple {
48
49struct ValidatorBlobInfo;
50class SHAMap;
51
52class PeerImp : public Peer,
53 public std::enable_shared_from_this<PeerImp>,
55{
56public:
59
60private:
62 using error_code = boost::system::error_code;
63 using socket_type = boost::asio::ip::tcp::socket;
64 using middle_type = boost::beast::tcp_stream;
65 using stream_type = boost::beast::ssl_stream<middle_type>;
66 using address_type = boost::asio::ip::address;
67 using endpoint_type = boost::asio::ip::tcp::endpoint;
69 boost::asio::basic_waitable_timer<std::chrono::steady_clock>;
71
73 id_t const id_;
81 boost::asio::strand<boost::asio::executor> strand_;
83
84 // Updated at each stage of the connection process to reflect
85 // the current conditions as closely as possible.
87
88 // These are up here to prevent warnings about order of initializations
89 //
91 bool const inbound_;
92
93 // Protocol version to use for this link
95
97 clock_type::time_point trackingTime_;
98 bool detaching_ = false;
99 // Node public key of peer.
103
104 // The indices of the smallest and largest ledgers this peer has available
105 //
110
111 boost::circular_buffer<uint256> recentLedgers_{128};
112 boost::circular_buffer<uint256> recentTxSets_{128};
113
116 clock_type::time_point lastPingTime_;
117 clock_type::time_point const creationTime_;
118
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
196
197 friend class OverlayImpl;
198
200 {
201 public:
202 Metrics() = default;
203 Metrics(Metrics const&) = delete;
204 Metrics&
205 operator=(Metrics const&) = delete;
206 Metrics(Metrics&&) = delete;
207 Metrics&
208 operator=(Metrics&&) = delete;
209
210 void
213 average_bytes() const;
215 total_bytes() const;
216
217 private:
219 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
220 clock_type::time_point intervalStart_{clock_type::now()};
224 };
225
226 struct
227 {
231
232public:
233 PeerImp(PeerImp const&) = delete;
234 PeerImp&
235 operator=(PeerImp const&) = delete;
236
238 PeerImp(
239 Application& app,
240 id_t id,
242 http_request_type&& request,
243 PublicKey const& publicKey,
245 Resource::Consumer consumer,
246 std::unique_ptr<stream_type>&& stream_ptr,
247 OverlayImpl& overlay);
248
250 // VFALCO legacyPublicKey should be implied by the Slot
251 template <class Buffers>
252 PeerImp(
253 Application& app,
254 std::unique_ptr<stream_type>&& stream_ptr,
255 Buffers const& buffers,
257 http_response_type&& response,
258 Resource::Consumer usage,
259 PublicKey const& publicKey,
261 id_t id,
262 OverlayImpl& overlay);
263
264 virtual ~PeerImp();
265
266 beast::Journal const&
267 pjournal() const
268 {
269 return p_journal_;
270 }
271
274 {
275 return slot_;
276 }
277
278 // Work-around for calling shared_from_this in constructors
279 virtual void
280 run();
281
282 // Called when Overlay gets a stop request.
283 void
284 stop() override;
285
286 //
287 // Network
288 //
289
290 void
291 send(std::shared_ptr<Message> const& m) override;
292
294 void
295 sendTxQueue() override;
296
300 void
301 addTxQueue(uint256 const& hash) override;
302
306 void
307 removeTxQueue(uint256 const& hash) override;
308
310 template <
311 class FwdIt,
312 class = typename std::enable_if_t<std::is_same<
314 PeerFinder::Endpoint>::value>>
315 void
316 sendEndpoints(FwdIt first, FwdIt last);
317
319 getRemoteAddress() const override
320 {
321 return remote_address_;
322 }
323
324 void
325 charge(Resource::Charge const& fee, std::string const& context) override;
326
327 //
328 // Identity
329 //
330
332 id() const override
333 {
334 return id_;
335 }
336
338 bool
339 crawl() const;
340
341 bool
342 cluster() const override;
343
347 void
348 checkTracking(std::uint32_t validationSeq);
349
350 void
352
353 PublicKey const&
354 getNodePublic() const override
355 {
356 return publicKey_;
357 }
358
361 getVersion() const;
362
363 // Return the connection elapsed time.
364 clock_type::duration
365 uptime() const
366 {
368 }
369
371 json() override;
372
373 bool
374 supportsFeature(ProtocolFeature f) const override;
375
377 publisherListSequence(PublicKey const& pubKey) const override
378 {
380
381 auto iter = publisherListSequences_.find(pubKey);
382 if (iter != publisherListSequences_.end())
383 return iter->second;
384 return {};
385 }
386
387 void
389 override
390 {
392
393 publisherListSequences_[pubKey] = seq;
394 }
395
396 //
397 // Ledger
398 //
399
400 uint256 const&
401 getClosedLedgerHash() const override
402 {
403 return closedLedgerHash_;
404 }
405
406 bool
407 hasLedger(uint256 const& hash, std::uint32_t seq) const override;
408
409 void
410 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
411
412 bool
413 hasTxSet(uint256 const& hash) const override;
414
415 void
416 cycleStatus() override;
417
418 bool
419 hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
420
421 // Called to determine our priority for querying
422 int
423 getScore(bool haveItem) const override;
424
425 bool
426 isHighLatency() const override;
427
428 void
429 fail(std::string const& reason);
430
431 bool
432 compressionEnabled() const override
433 {
434 return compressionEnabled_ == Compressed::On;
435 }
436
437 bool
438 txReduceRelayEnabled() const override
439 {
441 }
442
443private:
444 void
445 close();
446
447 void
448 fail(std::string const& name, error_code ec);
449
450 void
452
453 void
454 setTimer();
455
456 void
457 cancelTimer();
458
459 static std::string
460 makePrefix(id_t id);
461
462 // Called when the timer wait completes
463 void
464 onTimer(boost::system::error_code const& ec);
465
466 // Called when SSL shutdown completes
467 void
469
470 void
471 doAccept();
472
474 name() const;
475
477 domain() const;
478
479 //
480 // protocol message loop
481 //
482
483 // Starts the protocol message loop
484 void
486
487 // Called when protocol message bytes are received
488 void
489 onReadMessage(error_code ec, std::size_t bytes_transferred);
490
491 // Called when protocol messages bytes are sent
492 void
493 onWriteMessage(error_code ec, std::size_t bytes_transferred);
494
507 void
510 bool eraseTxQueue,
511 bool batch);
512
518 void
521
522public:
523 //--------------------------------------------------------------------------
524 //
525 // ProtocolStream
526 //
527 //--------------------------------------------------------------------------
528
529 void
531
532 void
534 std::uint16_t type,
536 std::size_t size,
537 std::size_t uncompressed_size,
538 bool isCompressed);
539
540 void
542 std::uint16_t type,
544
545 void
547 void
549 void
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
588private:
589 //--------------------------------------------------------------------------
590 // lockedRecentLock is passed as a reminder to callers that recentLock_
591 // must be locked.
592 void
593 addLedger(
594 uint256 const& hash,
595 std::lock_guard<std::mutex> const& lockedRecentLock);
596
597 void
599
600 void
602 std::string const& messageType,
603 std::string const& manifest,
604 std::uint32_t version,
605 std::vector<ValidatorBlobInfo> const& blobs);
606
611 void
613
614 void
616 HashRouterFlags flags,
617 bool checkSignature,
619 bool batch);
620
621 void
623 bool isTrusted,
625 RCLCxPeerPos peerPos);
626
627 void
630 uint256 const& key,
632
633 void
635 std::shared_ptr<Ledger const> const& ledger,
636 protocol::TMLedgerData& ledgerData);
637
640
643
644 void
646};
647
648//------------------------------------------------------------------------------
649
650template <class Buffers>
652 Application& app,
653 std::unique_ptr<stream_type>&& stream_ptr,
654 Buffers const& buffers,
656 http_response_type&& response,
657 Resource::Consumer usage,
658 PublicKey const& publicKey,
660 id_t id,
661 OverlayImpl& overlay)
662 : Child(overlay)
663 , app_(app)
664 , id_(id)
665 , sink_(app_.journal("Peer"), makePrefix(id))
666 , p_sink_(app_.journal("Protocol"), makePrefix(id))
667 , journal_(sink_)
668 , p_journal_(p_sink_)
669 , stream_ptr_(std::move(stream_ptr))
670 , socket_(stream_ptr_->next_layer().socket())
671 , stream_(*stream_ptr_)
672 , strand_(socket_.get_executor())
673 , timer_(waitable_timer{socket_.get_executor()})
674 , remote_address_(slot->remote_endpoint())
675 , overlay_(overlay)
676 , inbound_(false)
677 , protocol_(protocol)
678 , tracking_(Tracking::unknown)
679 , trackingTime_(clock_type::now())
680 , publicKey_(publicKey)
681 , lastPingTime_(clock_type::now())
682 , creationTime_(clock_type::now())
683 , squelch_(app_.journal("Squelch"))
684 , usage_(usage)
685 , fee_{Resource::feeTrivialPeer}
686 , slot_(std::move(slot))
687 , response_(std::move(response))
688 , headers_(response_)
689 , compressionEnabled_(
691 headers_,
693 "lz4",
694 app_.config().COMPRESSION)
695 ? Compressed::On
696 : Compressed::Off)
697 , txReduceRelayEnabled_(peerFeatureEnabled(
698 headers_,
700 app_.config().TX_REDUCE_RELAY_ENABLE))
701 , ledgerReplayEnabled_(peerFeatureEnabled(
702 headers_,
704 app_.config().LEDGER_REPLAY))
705 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
706{
707 read_buffer_.commit(boost::asio::buffer_copy(
708 read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
709 JLOG(journal_.info())
710 << "compression enabled " << (compressionEnabled_ == Compressed::On)
711 << " vp reduce-relay base squelch enabled "
713 headers_,
716 << " tx reduce-relay enabled " << txReduceRelayEnabled_ << " on "
717 << remote_address_ << " " << id_;
718}
719
720template <class FwdIt, class>
721void
722PeerImp::sendEndpoints(FwdIt first, FwdIt last)
723{
724 protocol::TMEndpoints tm;
725
726 while (first != last)
727 {
728 auto& tme2(*tm.add_endpoints_v2());
729 tme2.set_endpoint(first->address.to_string());
730 tme2.set_hops(first->hops);
731 first++;
732 }
733 tm.set_version(2);
734
735 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
736}
737
738} // namespace ripple
739
740#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
bool VP_REDUCE_RELAY_BASE_SQUELCH_ENABLE
Definition: Config.h:248
boost::circular_buffer< std::uint64_t > rollingAvg_
Definition: PeerImp.h:219
std::uint64_t accumBytes_
Definition: PeerImp.h:222
Metrics & operator=(Metrics const &)=delete
Metrics(Metrics &&)=delete
std::uint64_t total_bytes() const
Definition: PeerImp.cpp:3546
std::uint64_t totalBytes_
Definition: PeerImp.h:221
Metrics & operator=(Metrics &&)=delete
std::uint64_t average_bytes() const
Definition: PeerImp.cpp:3539
void add_message(std::uint64_t bytes)
Definition: PeerImp.cpp:3513
Metrics(Metrics const &)=delete
std::shared_mutex mutex_
Definition: PeerImp.h:218
std::uint64_t rollingAvgBytes_
Definition: PeerImp.h:223
clock_type::time_point intervalStart_
Definition: PeerImp.h:220
std::queue< std::shared_ptr< Message > > send_queue_
Definition: PeerImp.h:177
boost::beast::ssl_stream< middle_type > stream_type
Definition: PeerImp.h:65
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:2035
void onMessageEnd(std::uint16_t type, std::shared_ptr<::google::protobuf::Message > const &m)
Definition: PeerImp.cpp:1059
bool hasLedger(uint256 const &hash, std::uint32_t seq) const override
Definition: PeerImp.cpp:524
Metrics sent
Definition: PeerImp.h:228
clock_type::duration uptime() const
Definition: PeerImp.h:365
void removeTxQueue(uint256 const &hash) override
Remove transaction's hash from the transactions' hashes queue.
Definition: PeerImp.cpp:340
protocol::TMStatusChange last_status_
Definition: PeerImp.h:169
std::string name_
Definition: PeerImp.h:101
boost::circular_buffer< uint256 > recentTxSets_
Definition: PeerImp.h:112
std::unique_ptr< stream_type > stream_ptr_
Definition: PeerImp.h:78
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition: PeerImp.cpp:1068
bool detaching_
Definition: PeerImp.h:98
Tracking
Whether the peer's view of the ledger converges or diverges from ours.
Definition: PeerImp.h:58
Compressed compressionEnabled_
Definition: PeerImp.h:185
std::optional< std::size_t > publisherListSequence(PublicKey const &pubKey) const override
Definition: PeerImp.h:377
uint256 closedLedgerHash_
Definition: PeerImp.h:108
std::string domain() const
Definition: PeerImp.cpp:842
std::optional< std::uint32_t > lastPingSeq_
Definition: PeerImp.h:115
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition: PeerImp.h:273
void onTimer(boost::system::error_code const &ec)
Definition: PeerImp.cpp:690
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:722
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition: PeerImp.cpp:3118
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Definition: PeerImp.cpp:2754
boost::asio::ip::tcp::endpoint endpoint_type
Definition: PeerImp.h:67
beast::Journal const journal_
Definition: PeerImp.h:76
virtual void run()
Definition: PeerImp.cpp:156
boost::asio::ip::address address_type
Definition: PeerImp.h:66
struct ripple::PeerImp::@21 metrics_
void gracefulClose()
Definition: PeerImp.cpp:634
LedgerIndex maxLedger_
Definition: PeerImp.h:107
beast::Journal const p_journal_
Definition: PeerImp.h:77
void cancelTimer()
Definition: PeerImp.cpp:673
bool const inbound_
Definition: PeerImp.h:91
PeerImp(PeerImp const &)=delete
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3289
Application & app_
Definition: PeerImp.h:72
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition: PeerImp.cpp:3254
void stop() override
Definition: PeerImp.cpp:214
void checkTransaction(HashRouterFlags flags, bool checkSignature, std::shared_ptr< STTx const > const &stx, bool batch)
Definition: PeerImp.cpp:2843
bool hasRange(std::uint32_t uMin, std::uint32_t uMax) override
Definition: PeerImp.cpp:566
bool hasTxSet(uint256 const &hash) const override
Definition: PeerImp.cpp:548
clock_type::time_point lastPingTime_
Definition: PeerImp.h:116
void onMessageUnknown(std::uint16_t type)
Definition: PeerImp.cpp:1010
std::shared_ptr< PeerFinder::Slot > const slot_
Definition: PeerImp.h:172
std::shared_mutex nameMutex_
Definition: PeerImp.h:102
boost::circular_buffer< uint256 > recentLedgers_
Definition: PeerImp.h:111
id_t const id_
Definition: PeerImp.h:73
std::optional< std::chrono::milliseconds > latency_
Definition: PeerImp.h:114
void handleTransaction(std::shared_ptr< protocol::TMTransaction > const &m, bool eraseTxQueue, bool batch)
Called from onMessage(TMTransaction(s)).
Definition: PeerImp.cpp:1260
beast::IP::Endpoint const remote_address_
Definition: PeerImp.h:86
boost::asio::ip::tcp::socket socket_type
Definition: PeerImp.h:63
Json::Value json() override
Definition: PeerImp.cpp:389
PublicKey const publicKey_
Definition: PeerImp.h:100
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition: PeerImp.cpp:2738
hash_set< uint256 > txQueue_
Definition: PeerImp.h:190
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3158
std::mutex recentLock_
Definition: PeerImp.h:168
void doAccept()
Definition: PeerImp.cpp:767
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:1016
bool txReduceRelayEnabled_
Definition: PeerImp.h:192
beast::IP::Endpoint getRemoteAddress() const override
Definition: PeerImp.h:319
Metrics recv
Definition: PeerImp.h:229
clock_type::time_point trackingTime_
Definition: PeerImp.h:97
socket_type & socket_
Definition: PeerImp.h:79
ProtocolVersion protocol_
Definition: PeerImp.h:94
clock_type::time_point const creationTime_
Definition: PeerImp.h:117
reduce_relay::Squelch< UptimeClock > squelch_
Definition: PeerImp.h:119
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:381
uint256 previousLedgerHash_
Definition: PeerImp.h:109
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:352
void setTimer()
Definition: PeerImp.cpp:655
boost::beast::tcp_stream middle_type
Definition: PeerImp.h:64
int getScore(bool haveItem) const override
Definition: PeerImp.cpp:3468
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:2788
static std::string makePrefix(id_t id)
Definition: PeerImp.cpp:682
std::string name() const
Definition: PeerImp.cpp:835
boost::system::error_code error_code
Definition: PeerImp.h:62
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:890
bool ledgerReplayEnabled_
Definition: PeerImp.h:194
beast::WrappedSink p_sink_
Definition: PeerImp.h:75
boost::asio::basic_waitable_timer< std::chrono::steady_clock > waitable_timer
Definition: PeerImp.h:69
PublicKey const & getNodePublic() const override
Definition: PeerImp.h:354
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition: PeerImp.cpp:366
waitable_timer timer_
Definition: PeerImp.h:82
beast::Journal const & pjournal() const
Definition: PeerImp.h:267
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition: PeerImp.cpp:304
bool compressionEnabled() const override
Definition: PeerImp.h:432
bool txReduceRelayEnabled() const override
Definition: PeerImp.h:438
bool supportsFeature(ProtocolFeature f) const override
Definition: PeerImp.cpp:507
uint256 const & getClosedLedgerHash() const override
Definition: PeerImp.h:401
beast::WrappedSink sink_
Definition: PeerImp.h:74
ChargeWithContext fee_
Definition: PeerImp.h:171
void onWriteMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:954
http_request_type request_
Definition: PeerImp.h:174
OverlayImpl & overlay_
Definition: PeerImp.h:90
LedgerIndex minLedger_
Definition: PeerImp.h:106
virtual ~PeerImp()
Definition: PeerImp.cpp:133
Peer::id_t id() const override
Definition: PeerImp.h:332
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition: PeerImp.h:195
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:2618
void addTxQueue(uint256 const &hash) override
Add transaction's hash to the transactions' hashes queue.
Definition: PeerImp.cpp:323
int large_sendq_
Definition: PeerImp.h:179
stream_type & stream_
Definition: PeerImp.h:80
bool cluster() const override
Returns true if this connection is a member of the cluster.
Definition: PeerImp.cpp:375
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition: PeerImp.cpp:2978
bool isHighLatency() const override
Definition: PeerImp.cpp:3506
void checkTracking(std::uint32_t validationSeq)
Check if the peer is tracking.
Definition: PeerImp.cpp:1968
void onShutdown(error_code ec)
Definition: PeerImp.cpp:751
boost::asio::strand< boost::asio::executor > strand_
Definition: PeerImp.h:81
void cycleStatus() override
Definition: PeerImp.cpp:556
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:3021
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition: PeerImp.h:388
void ledgerRange(std::uint32_t &minSeq, std::uint32_t &maxSeq) const override
Definition: PeerImp.cpp:539
void doProtocolStart()
Definition: PeerImp.cpp:852
void fail(std::string const &reason)
Definition: PeerImp.cpp:600
std::atomic< Tracking > tracking_
Definition: PeerImp.h:96
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.
Definition: RCLCxPeerPos.h:44
A consumption charge.
Definition: Charge.h:30
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: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:154