20#ifndef RIPPLE_APP_LEDGER_OPENLEDGER_H_INCLUDED
21#define RIPPLE_APP_LEDGER_OPENLEDGER_H_INCLUDED
23#include <xrpld/app/ledger/Ledger.h>
24#include <xrpld/app/misc/CanonicalTXSet.h>
25#include <xrpld/core/Config.h>
26#include <xrpld/ledger/CachedSLEs.h>
27#include <xrpld/ledger/OpenView.h>
28#include <xrpl/basics/Log.h>
29#include <xrpl/basics/UnorderedContainers.h>
30#include <xrpl/beast/utility/Journal.h>
31#include <xrpl/beast/utility/instrumentation.h>
38#define LEDGER_TOTAL_PASSES 3
42#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 =
apply_one(app, view, tx,
true, flags, j);
228 if (result == Result::retry)
234 <<
"OpenLedger::apply: Caught exception: " << e.
what();
238 for (
int pass = 0; pass < LEDGER_TOTAL_PASSES; ++pass)
241 auto iter = retries.
begin();
242 while (iter != retries.
end())
246 case Result::success:
249 case Result::failure:
250 iter = retries.
erase(iter);
257 if (!changes && !
retry)
260 if (!changes || (pass >= LEDGER_RETRY_PASSES))
267 retries.
empty() || !
retry,
"ripple::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 end() const
const_iterator begin() const
const_iterator erase(const_iterator const &it)
Represents the open ledger.
bool modify(modify_type const &f)
Modify the open ledger.
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.
OpenLedger(OpenLedger const &)=delete
std::shared_ptr< OpenView > create(Rules const &rules, std::shared_ptr< Ledger const > const &ledger)
bool empty() const
Returns true if there are no transactions.
static void apply(Application &app, OpenView &view, ReadView const &check, FwdRange const &txs, OrderedTxs &retries, ApplyFlags flags, beast::Journal j)
Algorithm for applying transactions.
OpenLedger & operator=(OpenLedger const &)=delete
static Result apply_one(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, bool retry, ApplyFlags flags, beast::Journal j)
std::shared_ptr< OpenView const > current_
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
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.
boost::outcome_v2::result< T, std::error_code > Result
std::string debugTostr(OrderedTxs const &set)
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)