3#include <xrpld/core/Config.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/basics/UnorderedContainers.h>
7#include <xrpl/beast/utility/Journal.h>
8#include <xrpl/beast/utility/instrumentation.h>
9#include <xrpl/ledger/CachedSLEs.h>
10#include <xrpl/ledger/CanonicalTXSet.h>
11#include <xrpl/ledger/Ledger.h>
12#include <xrpl/ledger/OpenView.h>
21#define LEDGER_TOTAL_PASSES 3
25#define LEDGER_RETRY_PASSES 1
162 template <
class FwdRange>
190template <
class FwdRange>
201 for (
auto iter = txs.begin(); iter != txs.end(); ++iter)
206 auto const tx = *iter;
207 auto const txId = tx->getTransactionID();
208 if (check.txExists(txId))
210 auto const result =
applyOne(app, view, tx,
true, flags, j);
211 if (result == Result::Retry)
216 JLOG(j.
error()) <<
"OpenLedger::apply: Caught exception: " << e.
what();
220 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
223 auto iter = retries.
begin();
224 while (iter != retries.
end())
226 switch (
applyOne(app, view, iter->second, retry, flags, j))
228 case Result::Success:
231 case Result::Failure:
232 iter = retries.
erase(iter);
239 if (!changes && !retry)
242 if (!changes || (pass >= LEDGER_RETRY_PASSES))
248 XRPL_ASSERT(retries.
empty() || !retry,
"xrpl::OpenLedger::apply : valid retries");
A generic endpoint for log messages.
Holds transactions which were deferred to the next pass of consensus.
const_iterator begin() const
const_iterator erase(const_iterator const &it)
void insert(std::shared_ptr< STTx const > txn)
const_iterator end() const
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.
OpenLedger(OpenLedger const &)=delete
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_
OpenLedger & operator=(OpenLedger const &)=delete
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.
Rules controlling protocol behavior.
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
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,...
boost::outcome_v2::result< T, std::error_code > Result
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)
TaggedCache< uint256, SLE const > CachedSLEs
std::string debugTostr(OrderedTxs const &set)
CanonicalTXSet OrderedTxs