1#include <xrpld/app/ledger/OpenLedger.h>
2#include <xrpld/app/main/Application.h>
3#include <xrpld/app/misc/HashRouter.h>
4#include <xrpld/app/misc/TxQ.h>
5#include <xrpld/app/tx/apply.h>
6#include <xrpld/overlay/Message.h>
7#include <xrpld/overlay/Overlay.h>
9#include <xrpl/ledger/CachedView.h>
10#include <xrpl/protocol/TxFlags.h>
12#include <boost/range/adaptor/transformed.hpp>
20 : j_(journal), cache_(cache), current_(create(ledger->rules(), ledger))
43 auto const changed = f(*next,
j_);
64 JLOG(
j_.
trace()) <<
"accept ledger " << ledger->seq() <<
" " << suffix;
65 auto next =
create(rules, ledger);
83 boost::adaptors::transform(
98 for (
auto const& item : locals)
102 for (
auto const& txpair : next->txs)
104 auto const& tx = txpair.first;
105 auto const txId = tx->getTransactionID();
115 txpair.second && txpair.second->isFieldPresent(sfParentBatchID),
116 "Inner Batch transaction missing sfParentBatchID");
123 JLOG(
j_.
debug()) <<
"Relaying recovered tx " << txId;
124 protocol::TMTransaction msg;
128 msg.set_rawtransaction(s.
data(), s.
size());
129 msg.set_status(protocol::tsNEW);
130 msg.set_receivetimestamp(
166 auto const result =
xrpl::apply(app, view, *tx, flags, j);
167 if (result.applied || result.ter ==
terQUEUED)
168 return Result::success;
171 return Result::failure;
172 return Result::retry;
181 ss << tx->getTransactionID();
182 return ss.
str().substr(0, 4);
189 for (
auto const& item :
set)
198 for (
auto const& item :
set)
208 ss <<
"THROW:" << ex.
what() <<
", ";
218 for (
auto const& item : view->txs)
A generic endpoint for log messages.
Stream trace() const
Severity stream access functions.
virtual HashRouter & getHashRouter()=0
virtual TimeKeeper & timeKeeper()=0
virtual Overlay & overlay()=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.
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_
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.
virtual std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator)=0
Relay a proposal.
Rules controlling protocol behavior.
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.
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,...
constexpr struct xrpl::open_ledger_t open_ledger
ApplyResult apply(Application &app, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
constexpr std::uint32_t tfInnerBatchTxn
bool isTefFailure(TER x) noexcept
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)
std::string debugTostr(OrderedTxs const &set)
bool isTelLocal(TER x) noexcept
bool isTemMalformed(TER x) noexcept