3#include <xrpld/core/Config.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/beast/utility/instrumentation.h>
8#include <xrpl/core/PerfLog.h>
9#include <xrpl/ledger/ApplyView.h>
10#include <xrpl/ledger/CachedSLEs.h>
11#include <xrpl/ledger/CanonicalTXSet.h>
12#include <xrpl/ledger/Ledger.h>
13#include <xrpl/ledger/OpenView.h>
14#include <xrpl/ledger/ReadView.h>
15#include <xrpl/protocol/STTx.h>
16#include <xrpl/shamap/SHAMap.h>
29#define LEDGER_TOTAL_PASSES 3
33#define LEDGER_RETRY_PASSES 1
179 template <
class FwdRange>
207template <
class FwdRange>
218 for (
auto iter = txs.begin(); iter != txs.end(); ++iter)
223 auto const tx = *iter;
224 auto const txId = tx->getTransactionID();
225 if (check.txExists(txId))
227 auto const result =
applyOne(app, view, tx,
true, flags, j);
228 if (result == Result::Retry)
233 JLOG(j.
error()) <<
"OpenLedger::apply: Caught exception: " << e.
what();
237 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
240 auto iter = retries.
begin();
241 while (iter != retries.
end())
243 switch (
applyOne(app, view, iter->second, retry, flags, j))
245 case Result::Success:
248 case Result::Failure:
249 iter = retries.
erase(iter);
256 if (!changes && !retry)
259 if (!changes || (pass >= LEDGER_RETRY_PASSES))
265 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.
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