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
119
120 // Notes on thread locking:
121 //
122 // During an audit it was noted that some member variables that looked
123 // like they need thread protection were not receiving it. And, indeed,
124 // that was correct. But the multi-phase initialization of PeerImp
125 // makes such an audit difficult. A further audit suggests that the
126 // locking is now protecting variables that don't need it. We're
127 // leaving that locking in place (for now) as a form of future proofing.
128 //
129 // Here are the variables that appear to need locking currently:
130 //
131 // o closedLedgerHash_
132 // o previousLedgerHash_
133 // o minLedger_
134 // o maxLedger_
135 // o recentLedgers_
136 // o recentTxSets_
137 // o trackingTime_
138 // o latency_
139 //
140 // The following variables are being protected preemptively:
141 //
142 // o name_
143 // o last_status_
144 //
145 // June 2019
146
148 {
151
152 void
154 {
155 XRPL_ASSERT(
156 f >= fee,
157 "ripple::PeerImp::ChargeWithContext::update : 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
195
196 friend class OverlayImpl;
197
199 {
200 public:
201 Metrics() = default;
202 Metrics(Metrics const&) = delete;
203 Metrics&
204 operator=(Metrics const&) = delete;
205 Metrics(Metrics&&) = delete;
206 Metrics&
207 operator=(Metrics&&) = delete;
208
209 void
212 average_bytes() const;
214 total_bytes() const;
215
216 private:
217 boost::shared_mutex mutable mutex_;
218 boost::circular_buffer<std::uint64_t> rollingAvg_{30, 0ull};
219 clock_type::time_point intervalStart_{clock_type::now()};
223 };
224
225 struct
226 {
230
231public:
232 PeerImp(PeerImp const&) = delete;
233 PeerImp&
234 operator=(PeerImp const&) = delete;
235
237 PeerImp(
238 Application& app,
239 id_t id,
241 http_request_type&& request,
242 PublicKey const& publicKey,
244 Resource::Consumer consumer,
245 std::unique_ptr<stream_type>&& stream_ptr,
246 OverlayImpl& overlay);
247
249 // VFALCO legacyPublicKey should be implied by the Slot
250 template <class Buffers>
251 PeerImp(
252 Application& app,
253 std::unique_ptr<stream_type>&& stream_ptr,
254 Buffers const& buffers,
256 http_response_type&& response,
257 Resource::Consumer usage,
258 PublicKey const& publicKey,
260 id_t id,
261 OverlayImpl& overlay);
262
263 virtual ~PeerImp();
264
265 beast::Journal const&
266 pjournal() const
267 {
268 return p_journal_;
269 }
270
273 {
274 return slot_;
275 }
276
277 // Work-around for calling shared_from_this in constructors
278 virtual void
279 run();
280
281 // Called when Overlay gets a stop request.
282 void
283 stop() override;
284
285 //
286 // Network
287 //
288
289 void
290 send(std::shared_ptr<Message> const& m) override;
291
293 void
294 sendTxQueue() override;
295
299 void
300 addTxQueue(uint256 const& hash) override;
301
305 void
306 removeTxQueue(uint256 const& hash) override;
307
309 template <
310 class FwdIt,
311 class = typename std::enable_if_t<std::is_same<
313 PeerFinder::Endpoint>::value>>
314 void
315 sendEndpoints(FwdIt first, FwdIt last);
316
318 getRemoteAddress() const override
319 {
320 return remote_address_;
321 }
322
323 void
324 charge(Resource::Charge const& fee, std::string const& context) override;
325
326 //
327 // Identity
328 //
329
331 id() const override
332 {
333 return id_;
334 }
335
337 bool
338 crawl() const;
339
340 bool
341 cluster() const override;
342
346 void
347 checkTracking(std::uint32_t validationSeq);
348
349 void
351
352 PublicKey const&
353 getNodePublic() const override
354 {
355 return publicKey_;
356 }
357
360 getVersion() const;
361
362 // Return the connection elapsed time.
363 clock_type::duration
364 uptime() const
365 {
367 }
368
370 json() override;
371
372 bool
373 supportsFeature(ProtocolFeature f) const override;
374
376 publisherListSequence(PublicKey const& pubKey) const override
377 {
379
380 auto iter = publisherListSequences_.find(pubKey);
381 if (iter != publisherListSequences_.end())
382 return iter->second;
383 return {};
384 }
385
386 void
388 override
389 {
391
392 publisherListSequences_[pubKey] = seq;
393 }
394
395 //
396 // Ledger
397 //
398
399 uint256 const&
400 getClosedLedgerHash() const override
401 {
402 return closedLedgerHash_;
403 }
404
405 bool
406 hasLedger(uint256 const& hash, std::uint32_t seq) const override;
407
408 void
409 ledgerRange(std::uint32_t& minSeq, std::uint32_t& maxSeq) const override;
410
411 bool
412 hasTxSet(uint256 const& hash) const override;
413
414 void
415 cycleStatus() override;
416
417 bool
418 hasRange(std::uint32_t uMin, std::uint32_t uMax) override;
419
420 // Called to determine our priority for querying
421 int
422 getScore(bool haveItem) const override;
423
424 bool
425 isHighLatency() const override;
426
427 void
428 fail(std::string const& reason);
429
430 bool
431 compressionEnabled() const override
432 {
433 return compressionEnabled_ == Compressed::On;
434 }
435
436 bool
437 txReduceRelayEnabled() const override
438 {
440 }
441
442private:
443 void
444 close();
445
446 void
447 fail(std::string const& name, error_code ec);
448
449 void
451
452 void
453 setTimer();
454
455 void
456 cancelTimer();
457
458 static std::string
459 makePrefix(id_t id);
460
461 // Called when the timer wait completes
462 void
463 onTimer(boost::system::error_code const& ec);
464
465 // Called when SSL shutdown completes
466 void
468
469 void
470 doAccept();
471
473 name() const;
474
476 domain() const;
477
478 //
479 // protocol message loop
480 //
481
482 // Starts the protocol message loop
483 void
485
486 // Called when protocol message bytes are received
487 void
488 onReadMessage(error_code ec, std::size_t bytes_transferred);
489
490 // Called when protocol messages bytes are sent
491 void
492 onWriteMessage(error_code ec, std::size_t bytes_transferred);
493
506 void
509 bool eraseTxQueue,
510 bool batch);
511
517 void
520
521public:
522 //--------------------------------------------------------------------------
523 //
524 // ProtocolStream
525 //
526 //--------------------------------------------------------------------------
527
528 void
530
531 void
533 std::uint16_t type,
535 std::size_t size,
536 std::size_t uncompressed_size,
537 bool isCompressed);
538
539 void
541 std::uint16_t type,
543
544 void
546 void
548 void
550 void
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
587private:
588 //--------------------------------------------------------------------------
589 // lockedRecentLock is passed as a reminder to callers that recentLock_
590 // must be locked.
591 void
592 addLedger(
593 uint256 const& hash,
594 std::lock_guard<std::mutex> const& lockedRecentLock);
595
596 void
598
599 void
601 std::string const& messageType,
602 std::string const& manifest,
603 std::uint32_t version,
604 std::vector<ValidatorBlobInfo> const& blobs);
605
610 void
612
613 void
615 int flags,
616 bool checkSignature,
618 bool batch);
619
620 void
622 bool isTrusted,
624 RCLCxPeerPos peerPos);
625
626 void
629 uint256 const& key,
631
632 void
634 std::shared_ptr<Ledger const> const& ledger,
635 protocol::TMLedgerData& ledgerData);
636
639
642
643 void
645};
646
647//------------------------------------------------------------------------------
648
649template <class Buffers>
651 Application& app,
652 std::unique_ptr<stream_type>&& stream_ptr,
653 Buffers const& buffers,
655 http_response_type&& response,
656 Resource::Consumer usage,
657 PublicKey const& publicKey,
659 id_t id,
660 OverlayImpl& overlay)
661 : Child(overlay)
662 , app_(app)
663 , id_(id)
664 , sink_(app_.journal("Peer"), makePrefix(id))
665 , p_sink_(app_.journal("Protocol"), makePrefix(id))
666 , journal_(sink_)
667 , p_journal_(p_sink_)
668 , stream_ptr_(std::move(stream_ptr))
669 , socket_(stream_ptr_->next_layer().socket())
670 , stream_(*stream_ptr_)
671 , strand_(socket_.get_executor())
672 , timer_(waitable_timer{socket_.get_executor()})
673 , remote_address_(slot->remote_endpoint())
674 , overlay_(overlay)
675 , inbound_(false)
676 , protocol_(protocol)
677 , tracking_(Tracking::unknown)
678 , trackingTime_(clock_type::now())
679 , publicKey_(publicKey)
680 , lastPingTime_(clock_type::now())
681 , creationTime_(clock_type::now())
682 , squelch_(app_.journal("Squelch"))
683 , usage_(usage)
684 , fee_{Resource::feeTrivialPeer}
685 , slot_(std::move(slot))
686 , response_(std::move(response))
687 , headers_(response_)
688 , compressionEnabled_(
690 headers_,
692 "lz4",
693 app_.config().COMPRESSION)
694 ? Compressed::On
695 : Compressed::Off)
696 , txReduceRelayEnabled_(peerFeatureEnabled(
697 headers_,
699 app_.config().TX_REDUCE_RELAY_ENABLE))
700 , ledgerReplayEnabled_(peerFeatureEnabled(
701 headers_,
703 app_.config().LEDGER_REPLAY))
704 , ledgerReplayMsgHandler_(app, app.getLedgerReplayer())
705{
706 read_buffer_.commit(boost::asio::buffer_copy(
707 read_buffer_.prepare(boost::asio::buffer_size(buffers)), buffers));
708 JLOG(journal_.info())
709 << "compression enabled " << (compressionEnabled_ == Compressed::On)
710 << " vp reduce-relay base squelch enabled "
712 headers_,
715 << " tx reduce-relay enabled " << txReduceRelayEnabled_ << " on "
716 << remote_address_ << " " << id_;
717}
718
719template <class FwdIt, class>
720void
721PeerImp::sendEndpoints(FwdIt first, FwdIt last)
722{
723 protocol::TMEndpoints tm;
724
725 while (first != last)
726 {
727 auto& tme2(*tm.add_endpoints_v2());
728 tme2.set_endpoint(first->address.to_string());
729 tme2.set_hops(first->hops);
730 first++;
731 }
732 tm.set_version(2);
733
734 send(std::make_shared<Message>(tm, protocol::mtENDPOINTS));
735}
736
737} // namespace ripple
738
739#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
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:218
std::uint64_t accumBytes_
Definition: PeerImp.h:221
Metrics & operator=(Metrics const &)=delete
Metrics(Metrics &&)=delete
std::uint64_t total_bytes() const
Definition: PeerImp.cpp:3541
std::uint64_t totalBytes_
Definition: PeerImp.h:220
Metrics & operator=(Metrics &&)=delete
std::uint64_t average_bytes() const
Definition: PeerImp.cpp:3534
void add_message(std::uint64_t bytes)
Definition: PeerImp.cpp:3508
Metrics(Metrics const &)=delete
boost::shared_mutex mutex_
Definition: PeerImp.h:217
std::uint64_t rollingAvgBytes_
Definition: PeerImp.h:222
clock_type::time_point intervalStart_
Definition: PeerImp.h:219
std::queue< std::shared_ptr< Message > > send_queue_
Definition: PeerImp.h:176
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: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:227
clock_type::duration uptime() const
Definition: PeerImp.h:364
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: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:2843
void onMessage(std::shared_ptr< protocol::TMManifests > const &m)
Definition: PeerImp.cpp:1068
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:376
uint256 closedLedgerHash_
Definition: PeerImp.h:107
std::string domain() const
Definition: PeerImp.cpp:842
std::optional< std::uint32_t > lastPingSeq_
Definition: PeerImp.h:114
std::shared_ptr< PeerFinder::Slot > const & slot()
Definition: PeerImp.h:272
void onTimer(boost::system::error_code const &ec)
Definition: PeerImp.cpp:690
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:721
void sendLedgerBase(std::shared_ptr< Ledger const > const &ledger, protocol::TMLedgerData &ledgerData)
Definition: PeerImp.cpp:3113
void doFetchPack(std::shared_ptr< protocol::TMGetObjectByHash > const &packet)
Definition: PeerImp.cpp:2754
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
struct ripple::PeerImp::@21 metrics_
void gracefulClose()
Definition: PeerImp.cpp:634
LedgerIndex maxLedger_
Definition: PeerImp.h:106
beast::Journal const p_journal_
Definition: PeerImp.h:76
void cancelTimer()
Definition: PeerImp.cpp:673
bool const inbound_
Definition: PeerImp.h:90
PeerImp(PeerImp const &)=delete
void processLedgerRequest(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3284
Application & app_
Definition: PeerImp.h:71
std::shared_ptr< SHAMap const > getTxSet(std::shared_ptr< protocol::TMGetLedger > const &m) const
Definition: PeerImp.cpp:3249
void stop() override
Definition: PeerImp.cpp:214
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:115
void onMessageUnknown(std::uint16_t type)
Definition: PeerImp.cpp:1010
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:1260
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:389
PublicKey const publicKey_
Definition: PeerImp.h:99
void addLedger(uint256 const &hash, std::lock_guard< std::mutex > const &lockedRecentLock)
Definition: PeerImp.cpp:2738
hash_set< uint256 > txQueue_
Definition: PeerImp.h:189
std::shared_ptr< Ledger const > getLedger(std::shared_ptr< protocol::TMGetLedger > const &m)
Definition: PeerImp.cpp:3153
std::mutex recentLock_
Definition: PeerImp.h:167
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:191
beast::IP::Endpoint getRemoteAddress() const override
Definition: PeerImp.h:318
Metrics recv
Definition: PeerImp.h:228
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:381
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:352
void setTimer()
Definition: PeerImp.cpp:655
boost::beast::tcp_stream middle_type
Definition: PeerImp.h:63
int getScore(bool haveItem) const override
Definition: PeerImp.cpp:3463
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:61
void onReadMessage(error_code ec, std::size_t bytes_transferred)
Definition: PeerImp.cpp:890
bool ledgerReplayEnabled_
Definition: PeerImp.h:193
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:353
bool crawl() const
Returns true if this connection will publicly share its IP address.
Definition: PeerImp.cpp:366
waitable_timer timer_
Definition: PeerImp.h:81
beast::Journal const & pjournal() const
Definition: PeerImp.h:266
void sendTxQueue() override
Send aggregated transactions' hashes.
Definition: PeerImp.cpp:304
bool compressionEnabled() const override
Definition: PeerImp.h:431
bool txReduceRelayEnabled() const override
Definition: PeerImp.h:437
bool supportsFeature(ProtocolFeature f) const override
Definition: PeerImp.cpp:507
uint256 const & getClosedLedgerHash() const override
Definition: PeerImp.h:400
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:954
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:331
LedgerReplayMsgHandler ledgerReplayMsgHandler_
Definition: PeerImp.h:194
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: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:375
void checkPropose(bool isTrusted, std::shared_ptr< protocol::TMProposeSet > const &packet, RCLCxPeerPos peerPos)
Definition: PeerImp.cpp:2973
bool isHighLatency() const override
Definition: PeerImp.cpp:3501
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:80
void cycleStatus() override
Definition: PeerImp.cpp:556
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:3016
void setPublisherListSequence(PublicKey const &pubKey, std::size_t const seq) override
Definition: PeerImp.h:387
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: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: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.
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:153