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>
29#include <boost/range/adaptor/transformed.hpp>
37 : j_(journal), cache_(cache), current_(
create(ledger->rules(), ledger))
59 auto next = std::make_shared<OpenView>(*
current_);
60 auto const changed = f(*next,
j_);
81 JLOG(
j_.
trace()) <<
"accept ledger " << ledger->seq() <<
" " << suffix;
82 auto next =
create(rules, ledger);
100 boost::adaptors::transform(
115 for (
auto const& item : locals)
119 for (
auto const& txpair : next->txs)
121 auto const& tx = txpair.first;
122 auto const txId = tx->getTransactionID();
125 JLOG(
j_.
debug()) <<
"Relaying recovered tx " << txId;
126 protocol::TMTransaction msg;
130 msg.set_rawtransaction(s.
data(), s.
size());
131 msg.set_status(protocol::tsNEW);
132 msg.set_receivetimestamp(
150 return std::make_shared<OpenView>(
153 std::make_shared<CachedLedger const>(ledger,
cache_));
169 if (result.applied || result.ter ==
terQUEUED)
170 return Result::success;
173 return Result::failure;
174 return Result::retry;
183 ss << tx->getTransactionID();
184 return ss.
str().substr(0, 4);
191 for (
auto const& item :
set)
200 for (
auto const& item :
set)
205 auto const tx = std::make_shared<STTx const>(sit);
210 ss <<
"THROW:" << ex.
what() <<
", ";
220 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.
Json::Value create(AccountID const &account, AccountID const &to, STAmount const &amount, NetClock::duration const &settleDelay, PublicKey const &pk, std::optional< NetClock::time_point > const &cancelAfter, std::optional< std::uint32_t > const &dstTag)
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)