1#include <xrpld/app/ledger/OpenLedger.h>
3#include <xrpld/app/main/Application.h>
4#include <xrpld/app/misc/TxQ.h>
5#include <xrpld/overlay/Overlay.h>
7#include <xrpl/basics/Log.h>
8#include <xrpl/beast/utility/Journal.h>
9#include <xrpl/beast/utility/instrumentation.h>
10#include <xrpl/core/HashRouter.h>
11#include <xrpl/ledger/ApplyView.h>
12#include <xrpl/ledger/Ledger.h>
13#include <xrpl/ledger/OpenView.h>
14#include <xrpl/ledger/ReadView.h>
15#include <xrpl/protocol/Rules.h>
16#include <xrpl/protocol/SField.h>
17#include <xrpl/protocol/STObject.h>
18#include <xrpl/protocol/STTx.h>
19#include <xrpl/protocol/Serializer.h>
20#include <xrpl/protocol/TER.h>
21#include <xrpl/protocol/TxFlags.h>
22#include <xrpl/shamap/SHAMap.h>
23#include <xrpl/tx/apply.h>
25#include <boost/range/adaptor/transformed.hpp>
67 auto const changed = f(*next,
j_);
88 JLOG(
j_.trace()) <<
"accept ledger " << ledger->seq() <<
" " << suffix;
89 auto next =
create(rules, ledger);
94 apply(app, *next, *ledger, Empty{}, retries, flags,
j_);
107 boost::adaptors::transform(
110 p) { return p.first; }),
119 for (
auto const& item : locals)
123 for (
auto const& txpair : next->txs)
125 auto const& tx = txpair.first;
126 auto const txId = tx->getTransactionID();
136 txpair.second && txpair.second->isFieldPresent(sfParentBatchID),
137 "Inner Batch transaction missing sfParentBatchID");
144 JLOG(
j_.debug()) <<
"Relaying recovered tx " << txId;
145 protocol::TMTransaction msg;
149 msg.set_rawtransaction(s.
data(), s.
size());
150 msg.set_status(protocol::tsNEW);
181 auto const result =
xrpl::apply(app, view, *tx, flags, j);
182 if (result.applied || result.ter ==
terQUEUED)
183 return Result::Success;
185 return Result::Failure;
186 return Result::Retry;
195 ss << tx->getTransactionID();
196 return ss.
str().substr(0, 4);
203 for (
auto const& item :
set)
212 for (
auto const& item :
set)
222 ss <<
"THROW:" << ex.
what() <<
", ";
232 for (
auto const& item : view->txs)
A generic endpoint for log messages.
std::optional< std::set< PeerShortID > > shouldRelay(UInt256 const &key)
Determines whether the hashed item should be relayed.
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_view suffix="", ModifyType const &f={})
Accept a new ledger.
static Result applyOne(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, bool retry, ApplyFlags flags, beast::Journal j)
bool empty() const
Returns true if there are no transactions.
std::function< bool(OpenView &, beast::Journal)> ModifyType
Signature for modification functions.
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.
bool modify(ModifyType const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
virtual std::set< Peer::ID > relay(protocol::TMProposeSet const &m, UInt256 const &uid, PublicKey const &validator)=0
Relay a proposal.
Rules controlling protocol behavior.
std::size_t size() const noexcept
void const * data() const noexcept
virtual HashRouter & getHashRouter()=0
virtual Overlay & getOverlay()=0
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 FlagValue tfInnerBatchTxn
ApplyResult apply(ServiceRegistry ®istry, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
TaggedCache< UInt256, SLE const > CachedSLEs
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
constexpr struct xrpl::OpenLedgerT kOpenLedger
bool isTemMalformed(TER x) noexcept
CanonicalTXSet OrderedTxs