1#include <xrpld/app/ledger/InboundTransactions.h>
3#include <xrpld/app/ledger/detail/TransactionAcquire.h>
4#include <xrpld/app/main/Application.h>
5#include <xrpld/overlay/PeerSet.h>
7#include <xrpl/basics/Log.h>
8#include <xrpl/basics/Slice.h>
9#include <xrpl/basics/UnorderedContainers.h>
10#include <xrpl/beast/insight/Collector.h>
11#include <xrpl/protocol/RippleLedgerHash.h>
12#include <xrpl/resource/Fees.h>
13#include <xrpl/server/NetworkOPs.h>
14#include <xrpl/shamap/SHAMap.h>
15#include <xrpl/shamap/SHAMapMissingNode.h>
16#include <xrpl/shamap/SHAMapNodeID.h>
65 ,
j_(
app_.getJournal(
"InboundTransactions"))
78 auto it =
map_.find(hash);
81 return it->second.acquire;
94 if (
auto it =
map_.find(hash); it !=
map_.end())
98 it->second.seq =
seq_;
99 if (it->second.acquire)
101 it->second.acquire->stillNeed();
104 return it->second.set;
112 auto& obj =
map_[hash];
130 protocol::TMLedgerData
const& packet = *packetPtr;
132 JLOG(
j_.trace()) <<
"Got data (" << packet.nodes().size()
133 <<
") for acquiring ledger: " << hash;
144 data.reserve(packet.nodes().size());
146 for (
auto const& node : packet.nodes())
148 if (!node.has_nodeid() || !node.has_nodedata())
162 data.emplace_back(*
id,
makeSlice(node.nodedata()));
165 if (!ta->takeNodes(data, peer).isUseful())
177 auto& inboundSet =
map_[hash];
187 inboundSet.set =
set;
190 inboundSet.acquire.reset();
209 auto it =
map_.begin();
214 while (it !=
map_.end())
216 if (it->second.seq < minSeq || it->second.seq > maxSeq)
A generic endpoint for log messages.
std::shared_ptr< Collector > ptr
TransactionAcquire::pointer acquire
std::shared_ptr< SHAMap > set
InboundTransactionSet(std::uint32_t seq, std::shared_ptr< SHAMap > const &set)
void giveSet(uint256 const &hash, std::shared_ptr< SHAMap > const &set, bool fromAcquire) override
Add a transaction set.
TransactionAcquire::pointer getAcquire(uint256 const &hash)
std::unique_ptr< PeerSetBuilder > peerSetBuilder_
std::function< void(std::shared_ptr< SHAMap > const &, bool)> gotSet_
void gotData(LedgerHash const &hash, std::shared_ptr< Peer > peer, std::shared_ptr< protocol::TMLedgerData > packetPtr) override
We received a TMLedgerData from a peer.
void newRound(std::uint32_t seq) override
Informs the container if a new consensus round.
std::shared_ptr< SHAMap > getSet(uint256 const &hash, bool acquire) override
Find and return a transaction set, or nullptr if it is missing.
std::recursive_mutex lock_
hash_map< uint256, InboundTransactionSet > MapType
InboundTransactionsImp(Application &app, beast::insight::Collector::ptr const &collector, std::function< void(std::shared_ptr< SHAMap > const &, bool)> gotSet, std::unique_ptr< PeerSetBuilder > peerSetBuilder)
InboundTransactionSet & zeroSet_
InboundTransactions()=default
virtual ~InboundTransactions()=0
std::shared_ptr< TransactionAcquire > pointer
Charge const kFeeMalformedRequest
Schedule of fees charged for imposing load on the server.
Charge const kFeeInvalidData
Charge const kFeeUselessData
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::unique_ptr< InboundTransactions > makeInboundTransactions(Application &app, beast::insight::Collector::ptr const &collector, std::function< void(std::shared_ptr< SHAMap > const &, bool)> gotSet)
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
std::unique_ptr< PeerSetBuilder > makePeerSetBuilder(Application &app)
static constexpr auto kStartPeers
std::optional< SHAMapNodeID > deserializeSHAMapNodeID(void const *data, std::size_t size)
Return an object representing a serialized SHAMap Node ID.
std::unordered_map< Key, Value, Hash, Pred, Allocator > hash_map
static constexpr auto kSetKeepRounds
std::enable_if_t< std::is_same_v< T, char >||std::is_same_v< T, unsigned char >, Slice > makeSlice(std::array< T, N > const &a)