3#include <xrpld/app/ledger/Ledger.h>
4#include <xrpld/app/misc/CanonicalTXSet.h>
5#include <xrpld/core/Config.h>
7#include <xrpl/basics/Log.h>
8#include <xrpl/basics/UnorderedContainers.h>
9#include <xrpl/beast/utility/Journal.h>
10#include <xrpl/beast/utility/instrumentation.h>
11#include <xrpl/ledger/CachedSLEs.h>
12#include <xrpl/ledger/OpenView.h>
20#define LEDGER_TOTAL_PASSES 3
24#define LEDGER_RETRY_PASSES 1
158 template <
class FwdRange>
186template <
class FwdRange>
197 for (
auto iter = txs.begin(); iter != txs.end(); ++iter)
202 auto const tx = *iter;
203 auto const txId = tx->getTransactionID();
204 if (check.txExists(txId))
206 auto const result =
apply_one(app, view, tx,
true, flags, j);
207 if (result == Result::retry)
212 JLOG(j.
error()) <<
"OpenLedger::apply: Caught exception: " << e.
what();
216 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
219 auto iter = retries.
begin();
220 while (iter != retries.
end())
224 case Result::success:
227 case Result::failure:
228 iter = retries.
erase(iter);
235 if (!changes && !
retry)
238 if (!changes || (pass >= LEDGER_RETRY_PASSES))
244 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.
void insert(std::shared_ptr< STTx const > const &txn)
const_iterator begin() const
const_iterator erase(const_iterator const &it)
const_iterator end() const
Represents the open ledger.
bool modify(modify_type const &f)
Modify the open ledger.
OpenLedger(OpenLedger const &)=delete
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 const &suffix="", modify_type const &f={})
Accept a new ledger.
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.
static Result apply_one(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, bool retry, ApplyFlags flags, beast::Journal j)
std::mutex current_mutex_
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.
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)
std::string debugTostr(OrderedTxs const &set)
boost::outcome_v2::result< T, std::error_code > Result