3#include <test/jtx/PeerStub.h>
5#include <xrpld/app/ledger/ConsensusTransSetSF.h>
6#include <xrpld/overlay/Peer.h>
7#include <xrpld/overlay/PeerSet.h>
9#include <xrpl/basics/SHAMapHash.h>
10#include <xrpl/basics/base_uint.h>
11#include <xrpl/protocol/Serializer.h>
12#include <xrpl/resource/Charge.h>
13#include <xrpl/shamap/SHAMapAddNode.h>
14#include <xrpl/shamap/SHAMapNodeID.h>
15#include <xrpl/shamap/SHAMapTreeNode.h>
17#include <tests/libxrpl/shamap/DeepChain.h>
39using tests::DeepChain;
45 "a smallest-possible leaf must stay below the resubmission floor");
106 [[nodiscard]]
static ID
164 if (selected.
size() >= limit)
167 if (hasItem(candidate) &&
addedPeers_.insert(candidate->id()).second)
173 for (
auto const& peer : selected)
185 ::google::protobuf::Message
const&,
186 protocol::MessageType,
290 protocol::TMLedgerInfoType type = protocol::liTS_CANDIDATE,
297 packet->set_ledgerseq(ledgerSeq);
298 packet->set_type(type);
300 for (
auto const& [nodeID, node] : data)
303 node->serializeForWire(s);
305 auto*
const ledgerNode = packet->add_nodes();
312 ledgerNode->set_depth(nodeID.getDepth());
316 ledgerNode->set_id(nodeID.getRawString());
331[[nodiscard]]
inline bool
359[[nodiscard]]
inline bool
static constexpr std::size_t size()
static constexpr std::size_t kMinTxNodeBytesToParse
The size a node's hash-prefixed wire data must reach before gotNode() tries to parse and resubmit it ...
Supports data retrieval by managing a set of peers.
UInt256 const & asUInt256() const
Blob const & peekData() const
bool hasLedger(UInt256 const &, std::uint32_t) const override
std::vector< resource::Charge > charges_
ChargeRecordingPeer(bool hasTxSet=true)
void charge(resource::Charge const &fee, std::string const &) override
static ID nextId()
The next id to hand out, distinct per instance because RequestCountingPeerSet dedups by tracked id an...
bool hasTxSet(UInt256 const &) const override
std::vector< resource::Charge > const & charges() const
void addPeers(std::size_t limit, std::function< bool(std::shared_ptr< Peer > const &)> hasItem, std::function< void(std::shared_ptr< Peer > const &)> onPeerAdded) override
Offer the candidates to the caller, the way the real peer set offers the peers the overlay is trackin...
std::set< Peer::ID > addedPeers() const
A set, because onTimer() keeps re-offering the same candidates.
std::vector< std::shared_ptr< Peer > > const candidates_
std::optional< std::size_t > firstLimit() const
The limit the first addPeers() call asked for, which is init()'s, since onTimer() keeps calling addPe...
void sendRequest(::google::protobuf::Message const &, protocol::MessageType, std::shared_ptr< Peer > const &peer) override
Record the request, and record it in the broadcast count as well when it names no peer.
std::set< Peer::ID > addedPeers_
RequestCountingPeerSet(std::vector< std::shared_ptr< Peer > > candidates={})
std::optional< std::size_t > firstLimit_
int broadcasts() const
How many of those requests carried no peer of their own.
std::set< Peer::ID > const & getPeerIds() const override
The ids of every peer addPeers() has selected, which is what an acquisition takes for the peers it is...
static UInt256 ledgerHash(LedgerHeader const &info)
bool waitFor(std::function< bool()> const &condition, std::chrono::steady_clock::duration deadline=std::chrono::seconds{10})
Poll until the condition holds, or give up.
std::shared_ptr< protocol::TMLedgerData > packetFor(DeepChain const &chain, std::vector< std::pair< SHAMapNodeID, SHAMapTreeNodePtr > > const &data, protocol::TMLedgerInfoType type=protocol::liTS_CANDIDATE, std::optional< UInt256 > const &ledgerHash=std::nullopt, std::uint32_t ledgerSeq=0)
The given nodes of a chain as a TMLedgerData, so a test can go through the real dispatch.
bool tallyIs(SHAMapAddNode const &san, int good, int bad, int duplicate)
Whether a batch verdict carries exactly the given counts.
static constexpr std::size_t kLeafItemBytes
The payload size of the leaf toLeaf() builds, which is the smallest a SHAMap item may be.
A chain of inner nodes in wire form, from the root down to one deepest node, each with one real child...