20 #include <ripple/app/ledger/OpenLedger.h>
21 #include <ripple/app/main/Application.h>
22 #include <ripple/app/misc/HashRouter.h>
23 #include <ripple/app/misc/TxQ.h>
24 #include <ripple/app/tx/apply.h>
25 #include <ripple/ledger/CachedView.h>
26 #include <ripple/overlay/Message.h>
27 #include <ripple/overlay/Overlay.h>
28 #include <ripple/overlay/predicates.h>
29 #include <ripple/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.second || result.first ==
terQUEUED)
171 return Result::success;
174 return Result::failure;
175 return Result::retry;
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)
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
Stream trace() const
Severity stream access functions.
std::shared_ptr< OpenView const > current_
std::pair< TER, bool > apply(Application &app, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
const open_ledger_t open_ledger
std::pair< TER, bool > 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.
Writable ledger view that accumulates state and tx changes.
virtual TimeKeeper & timeKeeper()=0
static void apply(Application &app, OpenView &view, ReadView const &check, FwdRange const &txs, OrderedTxs &retries, ApplyFlags flags, beast::Journal j)
Algorithm for applying transactions.
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.
Holds transactions which were deferred to the next pass of consensus.
void const * data() const noexcept
A SHAMap is both a radix tree with a fan-out of 16 and a Merkle tree.
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,...
std::string debugTxstr(std::shared_ptr< STTx const > const &tx)
A generic endpoint for log messages.
virtual std::set< Peer::id_t > relay(protocol::TMProposeSet &m, uint256 const &uid, PublicKey const &validator)=0
Relay a proposal.
std::optional< std::set< PeerShortID > > shouldRelay(uint256 const &key)
Determines whether the hashed item should be relayed.
std::string debugTostr(OrderedTxs const &set)
bool empty() const
Returns true if there are no transactions.
uint256 getTransactionID() const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static Result apply_one(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, bool retry, ApplyFlags flags, beast::Journal j)
std::size_t size() const noexcept
virtual time_point now() const override=0
Returns the estimate of wall time, in network time.
virtual Overlay & overlay()=0
Rules controlling protocol behavior.
std::shared_ptr< OpenView > create(Rules const &rules, std::shared_ptr< Ledger const > const &ledger)
std::mutex current_mutex_
virtual HashRouter & getHashRouter()=0
bool modify(modify_type const &f)
Modify the open ledger.
bool isTemMalformed(TER x)