20 #ifndef RIPPLE_APP_LEDGER_OPENLEDGER_H_INCLUDED
21 #define RIPPLE_APP_LEDGER_OPENLEDGER_H_INCLUDED
23 #include <ripple/app/ledger/Ledger.h>
24 #include <ripple/ledger/CachedSLEs.h>
25 #include <ripple/ledger/OpenView.h>
26 #include <ripple/app/misc/CanonicalTXSet.h>
27 #include <ripple/basics/Log.h>
28 #include <ripple/basics/UnorderedContainers.h>
29 #include <ripple/core/Config.h>
30 #include <ripple/beast/utility/Journal.h>
38 #define LEDGER_TOTAL_PASSES 3
42 #define LEDGER_RETRY_PASSES 1
83 Ledger const>
const& ledger,
176 template <
class FwdRange>
180 ReadView const& check, FwdRange
const& txs,
206 template <
class FwdRange>
209 ReadView const& check, FwdRange
const& txs,
214 for (
auto iter = txs.begin();
215 iter != txs.end(); ++iter)
221 auto const tx = *iter;
222 auto const txId = tx->getTransactionID();
223 if (check.txExists(txId))
226 tx,
true, flags, shouldRecover[txId], j);
227 if (result == Result::retry)
238 pass < LEDGER_TOTAL_PASSES;
242 auto iter = retries.
begin();
243 while (iter != retries.
end())
246 iter->second,
retry, flags,
247 shouldRecover[iter->second->getTransactionID()], j))
249 case Result::success:
252 case Result::failure:
253 iter = retries.
erase (iter);
260 if (! changes && !
retry)
263 if (! changes || (pass >= LEDGER_RETRY_PASSES))
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
std::shared_ptr< OpenView const > current_
const_iterator erase(const_iterator const &it)
OpenLedger & operator=(OpenLedger const &)=delete
Writable ledger view that accumulates state and tx changes.
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.
Holds transactions which were deferred to the next pass of consensus.
const_iterator begin() const
Caches SLEs by their digest.
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
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,...
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)
A generic endpoint for log messages.
void insert(std::shared_ptr< STTx const > const &txn)
std::string debugTostr(OrderedTxs const &set)
bool empty() const
Returns true if there are no transactions.
const_iterator end() const
Represents the open ledger.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Rules controlling protocol behavior.
std::shared_ptr< OpenView > create(Rules const &rules, std::shared_ptr< Ledger const > const &ledger)
std::mutex current_mutex_
static Result apply_one(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, bool retry, ApplyFlags flags, bool shouldRecover, beast::Journal j)
static void apply(Application &app, OpenView &view, ReadView const &check, FwdRange const &txs, OrderedTxs &retries, ApplyFlags flags, std::map< uint256, bool > &shouldRecover, beast::Journal j)
Algorithm for applying transactions.
bool modify(modify_type const &f)
Modify the open ledger.