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/ledger/CachedView.h>
26#include <xrpld/overlay/Message.h>
27#include <xrpld/overlay/Overlay.h>
28#include <xrpld/overlay/predicates.h>
29#include <xrpl/protocol/Feature.h>
30#include <boost/range/adaptor/transformed.hpp>
38 : j_(journal), cache_(cache), current_(create(ledger->rules(), ledger))
60 auto next = std::make_shared<OpenView>(*
current_);
61 auto const changed = f(*next,
j_);
82 JLOG(
j_.
trace()) <<
"accept ledger " << ledger->seq() <<
" " << suffix;
83 auto next =
create(rules, ledger);
101 boost::adaptors::transform(
116 for (
auto const& item : locals)
120 for (
auto const& txpair : next->txs)
122 auto const& tx = txpair.first;
123 auto const txId = tx->getTransactionID();
126 JLOG(
j_.
debug()) <<
"Relaying recovered tx " << txId;
127 protocol::TMTransaction msg;
131 msg.set_rawtransaction(s.
data(), s.
size());
132 msg.set_status(protocol::tsNEW);
133 msg.set_receivetimestamp(
151 return std::make_shared<OpenView>(
154 std::make_shared<CachedLedger const>(ledger,
cache_));
170 if (result.applied || result.ter ==
terQUEUED)
171 return Result::success;
174 return Result::failure;
175 return Result::retry;
184 ss << tx->getTransactionID();
185 return ss.
str().substr(0, 4);
192 for (
auto const& item :
set)
201 for (
auto const& item :
set)
206 auto const tx = std::make_shared<STTx const>(sit);
211 ss <<
"THROW:" << ex.
what() <<
", ";
221 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.
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,...
bool isTemMalformed(TER x)
std::string debugTostr(OrderedTxs const &set)
open_ledger_t const open_ledger
ApplyResult apply(Application &app, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)