20#include <xrpld/app/ledger/OpenLedger.h>
21#include <xrpld/app/main/Application.h>
22#include <xrpld/app/misc/HashRouter.h>
23#include <xrpld/app/misc/TxQ.h>
24#include <xrpld/app/tx/apply.h>
25#include <xrpld/overlay/Message.h>
26#include <xrpld/overlay/Overlay.h>
28#include <xrpl/ledger/CachedView.h>
29#include <xrpl/protocol/TxFlags.h>
31#include <boost/range/adaptor/transformed.hpp>
39 : j_(journal), cache_(cache), current_(create(ledger->rules(), ledger))
62 auto const changed = f(*next,
j_);
83 JLOG(
j_.
trace()) <<
"accept ledger " << ledger->seq() <<
" " << suffix;
84 auto next =
create(rules, ledger);
102 boost::adaptors::transform(
117 for (
auto const& item : locals)
121 for (
auto const& txpair : next->txs)
123 auto const& tx = txpair.first;
124 auto const txId = tx->getTransactionID();
131 txpair.second && txpair.second->isFieldPresent(sfParentBatchID),
132 "Inner Batch transaction missing sfParentBatchID");
139 JLOG(
j_.
debug()) <<
"Relaying recovered tx " << txId;
140 protocol::TMTransaction msg;
144 msg.set_rawtransaction(s.
data(), s.
size());
145 msg.set_status(protocol::tsNEW);
146 msg.set_receivetimestamp(
183 if (result.applied || result.ter ==
terQUEUED)
184 return Result::success;
187 return Result::failure;
188 return Result::retry;
197 ss << tx->getTransactionID();
198 return ss.
str().substr(0, 4);
205 for (
auto const& item :
set)
214 for (
auto const& item :
set)
224 ss <<
"THROW:" << ex.
what() <<
", ";
234 for (
auto const& item : view->txs)
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
virtual Overlay & overlay()=0
virtual TimeKeeper & timeKeeper()=0
virtual HashRouter & getHashRouter()=0
Holds transactions which were deferred to the next pass of consensus.
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
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.
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.
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.
virtual std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator)=0
Relay a proposal.
Rules controlling protocol behavior.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
std::size_t size() const noexcept
void const * data() const noexcept
time_point now() const override
Returns the current time, using the server's clock.
ApplyResult apply(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, ApplyFlags flags, beast::Journal j)
Add a new transaction to the open ledger, hold it in the queue, or reject it.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr struct ripple::open_ledger_t open_ledger
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,...
bool isTefFailure(TER x) noexcept
std::string debugTostr(OrderedTxs const &set)
ApplyResult apply(Application &app, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
bool isTemMalformed(TER x) noexcept
bool isTelLocal(TER x) noexcept
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)
constexpr std::uint32_t tfInnerBatchTxn