1#include <xrpld/app/ledger/OpenLedger.h>
3#include <xrpld/app/main/Application.h>
4#include <xrpld/app/misc/TxQ.h>
5#include <xrpld/core/TimeKeeper.h>
6#include <xrpld/overlay/Overlay.h>
8#include <xrpl/basics/Log.h>
9#include <xrpl/beast/utility/Journal.h>
10#include <xrpl/beast/utility/instrumentation.h>
11#include <xrpl/core/HashRouter.h>
12#include <xrpl/ledger/ApplyView.h>
13#include <xrpl/ledger/Ledger.h>
14#include <xrpl/ledger/OpenView.h>
15#include <xrpl/ledger/ReadView.h>
16#include <xrpl/protocol/Rules.h>
17#include <xrpl/protocol/SField.h>
18#include <xrpl/protocol/STObject.h>
19#include <xrpl/protocol/STTx.h>
20#include <xrpl/protocol/Serializer.h>
21#include <xrpl/protocol/TER.h>
22#include <xrpl/protocol/TxFlags.h>
23#include <xrpl/shamap/SHAMap.h>
24#include <xrpl/tx/apply.h>
26#include <boost/range/adaptor/transformed.hpp>
68 auto const changed = f(*next,
j_);
89 JLOG(
j_.trace()) <<
"accept ledger " << ledger->seq() <<
" " << suffix;
90 auto next =
create(rules, ledger);
108 boost::adaptors::transform(
111 p) { return p.first; }),
120 for (
auto const& item : locals)
124 for (
auto const& txpair : next->txs)
126 auto const& tx = txpair.first;
127 auto const txId = tx->getTransactionID();
137 txpair.second && txpair.second->isFieldPresent(sfParentBatchID),
138 "Inner Batch transaction missing sfParentBatchID");
145 JLOG(
j_.debug()) <<
"Relaying recovered tx " << txId;
146 protocol::TMTransaction msg;
150 msg.set_rawtransaction(s.
data(), s.
size());
151 msg.set_status(protocol::tsNEW);
152 msg.set_receivetimestamp(app.
getTimeKeeper().
now().time_since_epoch().count());
183 auto const result =
xrpl::apply(app, view, *tx, flags, j);
184 if (result.applied || result.ter ==
terQUEUED)
185 return Result::Success;
187 return Result::Failure;
188 return Result::Retry;
197 ss << tx->getTransactionID();
198 return ss.
str().substr(0, 4);
205 for (
auto const& item :
set)
214 for (
auto const& item :
set)
224 ss <<
"THROW:" << ex.
what() <<
", ";
234 for (
auto const& item : view->txs)
A generic endpoint for log messages.
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
static Result applyOne(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, bool retry, ApplyFlags flags, beast::Journal j)
bool modify(modify_type const &f)
Modify the open ledger.
std::function< bool(OpenView &, beast::Journal)> modify_type
Signature for modification functions.
bool empty() const
Returns true if there are no transactions.
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
std::shared_ptr< OpenView > create(Rules const &rules, std::shared_ptr< Ledger const > const &ledger)
std::shared_ptr< OpenView const > current_
static void apply(Application &app, OpenView &view, ReadView const &check, FwdRange const &txs, OrderedTxs &retries, ApplyFlags flags, beast::Journal j)
Algorithm for applying transactions.
void accept(Application &app, Rules const &rules, std::shared_ptr< Ledger const > const &ledger, OrderedTxs const &locals, bool retriesFirst, OrderedTxs &retries, ApplyFlags flags, std::string_view suffix="", modify_type const &f={})
Accept a new ledger.
Writable ledger view that accumulates state and tx changes.
virtual std::set< Peer::id_t > relay(protocol::TMProposeSet const &m, uint256 const &uid, PublicKey const &validator)=0
Relay a proposal.
Rules controlling protocol behavior.
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
std::size_t size() const noexcept
void const * data() const noexcept
virtual HashRouter & getHashRouter()=0
virtual Overlay & getOverlay()=0
virtual TimeKeeper & getTimeKeeper()=0
time_point now() const override
Returns the current time, using the server's clock.
ApplyResult apply(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, ApplyFlags flags, beast::Journal j)
Add a new transaction to the open ledger, hold it in the queue, or reject it.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
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,...
constexpr FlagValue tfInnerBatchTxn
ApplyResult apply(ServiceRegistry ®istry, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
bool isTefFailure(TER x) noexcept
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)
TaggedCache< uint256, SLE const > CachedSLEs
std::string debugTostr(OrderedTxs const &set)
bool isTelLocal(TER x) noexcept
constexpr struct xrpl::OpenLedgerT kOpenLedger
bool isTemMalformed(TER x) noexcept
CanonicalTXSet OrderedTxs