rippled
TxQ.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012-19 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_TXQ_H_INCLUDED
21 #define RIPPLE_TXQ_H_INCLUDED
22 
23 #include <ripple/app/tx/applySteps.h>
24 #include <ripple/ledger/ApplyView.h>
25 #include <ripple/ledger/OpenView.h>
26 #include <ripple/protocol/STTx.h>
27 #include <ripple/protocol/SeqProxy.h>
28 #include <ripple/protocol/TER.h>
29 #include <boost/circular_buffer.hpp>
30 #include <boost/intrusive/set.hpp>
31 #include <optional>
32 
33 namespace ripple {
34 
35 class Application;
36 class Config;
37 
56 class TxQ
57 {
58 public:
60  static constexpr FeeLevel64 baseLevel{256};
61 
65  struct Setup
66  {
68  explicit Setup() = default;
69 
153  bool standAlone = false;
154  };
155 
160  struct Metrics
161  {
163  explicit Metrics() = default;
164 
183  };
184 
190  struct TxDetails
191  {
194  FeeLevel64 feeLevel_,
195  std::optional<LedgerIndex> const& lastValid_,
196  TxConsequences const& consequences_,
197  AccountID const& account_,
198  SeqProxy seqProxy_,
199  std::shared_ptr<STTx const> const& txn_,
200  int retriesRemaining_,
201  TER preflightResult_,
202  std::optional<TER> lastResult_)
203  : feeLevel(feeLevel_)
204  , lastValid(lastValid_)
205  , consequences(consequences_)
206  , account(account_)
207  , seqProxy(seqProxy_)
208  , txn(txn_)
209  , retriesRemaining(retriesRemaining_)
210  , preflightResult(preflightResult_)
211  , lastResult(lastResult_)
212  {
213  }
214 
252  };
253 
255  TxQ(Setup const& setup, beast::Journal j);
256 
258  virtual ~TxQ();
259 
270  apply(
271  Application& app,
272  OpenView& view,
273  std::shared_ptr<STTx const> const& tx,
274  ApplyFlags flags,
275  beast::Journal j);
276 
288  bool
289  accept(Application& app, OpenView& view);
290 
303  void
304  processClosedLedger(Application& app, ReadView const& view, bool timeLeap);
305 
307  SeqProxy
308  nextQueuableSeq(std::shared_ptr<SLE const> const& sleAccount) const;
309 
312  Metrics
313  getMetrics(OpenView const& view) const;
314 
315  struct FeeAndSeq
316  {
320  };
321 
331  FeeAndSeq
333  OpenView const& view,
334  std::shared_ptr<STTx const> const& tx) const;
335 
343  getAccountTxs(AccountID const& account, ReadView const& view) const;
344 
352  getTxs(ReadView const& view) const;
353 
359  doRPC(Application& app) const;
360 
361 private:
362  // Implementation for nextQueuableSeq(). The passed lock must be held.
363  SeqProxy
365  std::shared_ptr<SLE const> const& sleAccount,
366  std::lock_guard<std::mutex> const&) const;
367 
374  {
375  private:
389  boost::circular_buffer<std::size_t> recentTxnCounts_;
395 
396  public:
398  FeeMetrics(Setup const& setup, beast::Journal j)
400  setup.standAlone ? setup.minimumTxnInLedgerSA
401  : setup.minimumTxnInLedger)
402  , targetTxnCount_(
403  setup.targetTxnInLedger < minimumTxnCount_
405  : setup.targetTxnInLedger)
407  setup.maximumTxnInLedger
408  ? *setup.maximumTxnInLedger < targetTxnCount_
410  : *setup.maximumTxnInLedger
411  : std::optional<std::size_t>(std::nullopt))
413  , recentTxnCounts_(setup.ledgersInQueue)
414  , escalationMultiplier_(setup.minimumEscalationMultiplier)
415  , j_(j)
416  {
417  }
418 
430  update(
431  Application& app,
432  ReadView const& view,
433  bool timeLeap,
434  TxQ::Setup const& setup);
435 
438  struct Snapshot
439  {
440  // Number of transactions expected per ledger.
441  // One more than this value will be accepted
442  // before escalation kicks in.
444  // Based on the median fee of the LCL. Used
445  // when fee escalation kicks in.
447  };
448 
450  Snapshot
451  getSnapshot() const
452  {
454  }
455 
464  static FeeLevel64
465  scaleFeeLevel(Snapshot const& snapshot, OpenView const& view);
466 
499  Snapshot const& snapshot,
500  OpenView const& view,
501  std::size_t extraCount,
502  std::size_t seriesSize);
503  };
504 
509  class MaybeTx
510  {
511  public:
515  boost::intrusive::set_member_hook<> byFeeListHook;
516 
519 
523  TxID const txID;
561 
576  static constexpr int retriesAllowed = 10;
577 
578  public:
580  MaybeTx(
582  TxID const& txID,
584  ApplyFlags const flags,
585  PreflightResult const& pfresult);
586 
589  apply(Application& app, OpenView& view, beast::Journal j);
590 
593  TxConsequences const&
594  consequences() const
595  {
596  return pfresult->consequences;
597  }
598 
600  TxDetails
601  getTxDetails() const
602  {
603  return {
604  feeLevel,
605  lastValid,
606  consequences(),
607  account,
608  seqProxy,
609  txn,
611  pfresult->ter,
612  lastResult};
613  }
614  };
615 
618  {
619  public:
621  explicit OrderCandidates() = default;
622 
635  bool
636  operator()(const MaybeTx& lhs, const MaybeTx& rhs) const
637  {
638  if (lhs.feeLevel == rhs.feeLevel)
639  return lhs.txID < rhs.txID;
640  return lhs.feeLevel > rhs.feeLevel;
641  }
642  };
643 
648  {
649  public:
651 
656  /* If this account has had any transaction retry more than
657  `retriesAllowed` times so that it was dropped from the
658  queue, then all other transactions for this account will
659  be given at most 2 attempts before being removed. Helps
660  prevent wasting resources on retries that are more likely
661  to fail.
662  */
663  bool retryPenalty = false;
664  /* If this account has had any transaction fail or expire,
665  then when the queue is nearly full, transactions from
666  this account will be discarded. Helps prevent the queue
667  from getting filled and wedged.
668  */
669  bool dropPenalty = false;
670 
671  public:
673  explicit TxQAccount(std::shared_ptr<STTx const> const& txn);
675  explicit TxQAccount(const AccountID& account);
676 
679  getTxnCount() const
680  {
681  return transactions.size();
682  }
683 
685  bool
686  empty() const
687  {
688  return !getTxnCount();
689  }
690 
692  TxMap::const_iterator
693  getPrevTx(SeqProxy seqProx) const;
694 
696  MaybeTx&
697  add(MaybeTx&&);
698 
704  bool
705  remove(SeqProxy seqProx);
706  };
707 
708  // Helper function returns requiredFeeLevel.
709  FeeLevel64
711  OpenView& view,
712  ApplyFlags flags,
713  FeeMetrics::Snapshot const& metricsSnapshot,
714  std::lock_guard<std::mutex> const& lock) const;
715 
716  // Helper function for TxQ::apply. If a transaction's fee is high enough,
717  // attempt to directly apply that transaction to the ledger.
720  Application& app,
721  OpenView& view,
722  std::shared_ptr<STTx const> const& tx,
723  ApplyFlags flags,
724  beast::Journal j);
725 
726  // Helper function that removes a replaced entry in _byFee.
729  std::optional<TxQAccount::TxMap::iterator> const& replacedTxIter,
730  std::shared_ptr<STTx const> const& tx);
731 
732  using FeeHook = boost::intrusive::member_hook<
733  MaybeTx,
734  boost::intrusive::set_member_hook<>,
736 
737  using FeeMultiSet = boost::intrusive::
738  multiset<MaybeTx, FeeHook, boost::intrusive::compare<OrderCandidates>>;
739 
741 
743  Setup const setup_;
746 
772 
777 
778 private:
780  template <size_t fillPercentage = 100>
781  bool
782  isFull() const;
783 
787  TER
788  canBeHeld(
789  STTx const&,
790  ApplyFlags const,
791  OpenView const&,
792  std::shared_ptr<SLE const> const& sleAccount,
793  AccountMap::iterator const&,
795  std::lock_guard<std::mutex> const& lock);
796 
798  FeeMultiSet::iterator_type erase(FeeMultiSet::const_iterator_type);
803  FeeMultiSet::iterator_type eraseAndAdvance(
804  FeeMultiSet::const_iterator_type);
806  TxQAccount::TxMap::iterator
807  erase(
808  TxQAccount& txQAccount,
809  TxQAccount::TxMap::const_iterator begin,
810  TxQAccount::TxMap::const_iterator end);
811 
819  Application& app,
820  OpenView& view,
821  STTx const& tx,
822  AccountMap::iterator const& accountIter,
823  TxQAccount::TxMap::iterator,
824  FeeLevel64 feeLevelPaid,
825  PreflightResult const& pfresult,
826  std::size_t const txExtraCount,
827  ApplyFlags flags,
828  FeeMetrics::Snapshot const& metricsSnapshot,
829  beast::Journal j);
830 };
831 
836 setup_TxQ(Config const&);
837 
838 template <class T>
839 XRPAmount
840 toDrops(FeeLevel<T> const& level, XRPAmount const& baseFee)
841 {
842  if (auto const drops = mulDiv(level, baseFee, TxQ::baseLevel); drops.first)
843  return drops.second;
844 
846 }
847 
848 inline FeeLevel64
849 toFeeLevel(XRPAmount const& drops, XRPAmount const& baseFee)
850 {
851  if (auto const feeLevel = mulDiv(drops, TxQ::baseLevel, baseFee);
852  feeLevel.first)
853  return feeLevel.second;
854 
856 }
857 
858 } // namespace ripple
859 
860 #endif
ripple::TxQ::setup_
const Setup setup_
Setup parameters used to control the behavior of the queue.
Definition: TxQ.h:743
ripple::setup_TxQ
TxQ::Setup setup_TxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
Definition: TxQ.cpp:1823
ripple::TxQ::Metrics::Metrics
Metrics()=default
Default constructor.
ripple::TxQ::tryClearAccountQueueUpThruTx
std::pair< TER, bool > tryClearAccountQueueUpThruTx(Application &app, OpenView &view, STTx const &tx, AccountMap::iterator const &accountIter, TxQAccount::TxMap::iterator, FeeLevel64 feeLevelPaid, PreflightResult const &pfresult, std::size_t const txExtraCount, ApplyFlags flags, FeeMetrics::Snapshot const &metricsSnapshot, beast::Journal j)
All-or-nothing attempt to try to apply the queued txs for accountIter up to and including tx.
Definition: TxQ.cpp:499
ripple::Application
Definition: Application.h:115
ripple::TxQ::TxDetails::lastValid
std::optional< LedgerIndex > lastValid
LastValidLedger field of the queued transaction, if any.
Definition: TxQ.h:218
ripple::TxQ::Metrics::minProcessingFeeLevel
FeeLevel64 minProcessingFeeLevel
Minimum fee level for a transaction to be considered for the open ledger or the queue.
Definition: TxQ.h:177
std::shared_ptr
STL class.
ripple::TxQ::getTxs
std::vector< TxDetails > getTxs(ReadView const &view) const
Returns information about all transactions currently in the queue.
Definition: TxQ.cpp:1764
ripple::TxQ::MaybeTx::txn
std::shared_ptr< STTx const > txn
The complete transaction.
Definition: TxQ.h:518
ripple::TxQ::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:745
ripple::TxQ::TxDetails::seqProxy
SeqProxy seqProxy
SeqProxy of the transaction.
Definition: TxQ.h:226
std::pair
ripple::TxQ::apply
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.
Definition: TxQ.cpp:709
ripple::TxQ::removeFromByFee
std::optional< TxQAccount::TxMap::iterator > removeFromByFee(std::optional< TxQAccount::TxMap::iterator > const &replacedTxIter, std::shared_ptr< STTx const > const &tx)
Definition: TxQ.cpp:1680
ripple::TxQ::FeeMetrics::FeeMetrics
FeeMetrics(Setup const &setup, beast::Journal j)
Constructor.
Definition: TxQ.h:398
ripple::TxQ::OrderCandidates::OrderCandidates
OrderCandidates()=default
Default constructor.
ripple::OpenView
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:55
ripple::TxQ::MaybeTx::lastResult
std::optional< TER > lastResult
If the transactor attempted to apply the transaction to the open ledger from the queue and failed,...
Definition: TxQ.h:551
std::vector
STL class.
ripple::TxQ::TxQAccount
Used to represent an account to the queue, and stores the transactions queued for that account by Seq...
Definition: TxQ.h:647
std::map::size
T size(T... args)
ripple::TxQ::eraseAndAdvance
FeeMultiSet::iterator_type eraseAndAdvance(FeeMultiSet::const_iterator_type)
Erase and return the next entry for the account (if fee level is higher), or next entry in byFee_ (lo...
Definition: TxQ.cpp:451
ripple::TxQ::erase
FeeMultiSet::iterator_type erase(FeeMultiSet::const_iterator_type)
Erase and return the next entry in byFee_ (lower fee level)
ripple::TxQ::FeeMetrics
Track and use the fee escalation metrics of the current open ledger.
Definition: TxQ.h:373
ripple::ApplyFlags
ApplyFlags
Definition: ApplyView.h:29
ripple::FeeLevel64
FeeLevel< std::uint64_t > FeeLevel64
Definition: FeeUnits.h:464
ripple::TxQ::FeeMetrics::getSnapshot
Snapshot getSnapshot() const
Get the current Snapshot.
Definition: TxQ.h:451
std::lock_guard
STL class.
ripple::TxQ::TxDetails
Structure that describes a transaction in the queue waiting to be applied to the current open ledger.
Definition: TxQ.h:190
ripple::TxQ::nextQueuableSeqImpl
SeqProxy nextQueuableSeqImpl(std::shared_ptr< SLE const > const &sleAccount, std::lock_guard< std::mutex > const &) const
Definition: TxQ.cpp:1552
ripple::TxQ::TxQAccount::remove
bool remove(SeqProxy seqProx)
Remove the candidate with given SeqProxy value from this account.
Definition: TxQ.cpp:341
ripple::TxQ::MaybeTx::flags
const ApplyFlags flags
Flags provided to apply.
Definition: TxQ.h:544
ripple::TxQ::FeeMetrics::escalationMultiplier_
FeeLevel64 escalationMultiplier_
Based on the median fee of the LCL.
Definition: TxQ.h:392
ripple::TxQ::isFull
bool isFull() const
Is the queue at least fillPercentage full?
Definition: TxQ.cpp:360
ripple::TxQ::FeeAndSeq
Definition: TxQ.h:315
ripple::TxQ::canBeHeld
TER canBeHeld(STTx const &, ApplyFlags const, OpenView const &, std::shared_ptr< SLE const > const &sleAccount, AccountMap::iterator const &, std::optional< TxQAccount::TxMap::iterator > const &, std::lock_guard< std::mutex > const &lock)
Checks if the indicated transaction fits the conditions for being stored in the queue.
Definition: TxQ.cpp:368
ripple::toFeeLevel
FeeLevel64 toFeeLevel(XRPAmount const &drops, XRPAmount const &baseFee)
Definition: TxQ.h:849
ripple::TxQ::FeeMetrics::maximumTxnCount_
const std::optional< std::size_t > maximumTxnCount_
Maximum value of txnsExpected.
Definition: TxQ.h:382
ripple::TxQ::FeeMetrics::recentTxnCounts_
boost::circular_buffer< std::size_t > recentTxnCounts_
Recent history of transaction counts that exceed the targetTxnCount_.
Definition: TxQ.h:389
ripple::TxQ::MaybeTx::apply
std::pair< TER, bool > apply(Application &app, OpenView &view, beast::Journal j)
Attempt to apply the queued transaction to the open ledger.
Definition: TxQ.cpp:287
ripple::TxQ::TxQAccount::transactions
TxMap transactions
Sequence number will be used as the key.
Definition: TxQ.h:655
ripple::TxQ::Metrics
Structure returned by TxQ::getMetrics, expressed in reference fee level units.
Definition: TxQ.h:160
ripple::TxQ::accept
bool accept(Application &app, OpenView &view)
Fill the new open ledger with transactions from the queue.
Definition: TxQ.cpp:1399
ripple::TxQ::Setup::maximumTxnPerAccount
std::uint32_t maximumTxnPerAccount
Maximum number of transactions that can be queued by one account.
Definition: TxQ.h:144
ripple::TxQ::FeeHook
boost::intrusive::member_hook< MaybeTx, boost::intrusive::set_member_hook<>, &MaybeTx::byFeeListHook > FeeHook
Definition: TxQ.h:735
ripple::TxQ::FeeMetrics::update
std::size_t update(Application &app, ReadView const &view, bool timeLeap, TxQ::Setup const &setup)
Updates fee metrics based on the transactions in the ReadView for use in fee escalation calculations.
Definition: TxQ.cpp:84
ripple::TxQ::MaybeTx::getTxDetails
TxDetails getTxDetails() const
Return a TxDetails based on contained information.
Definition: TxQ.h:601
ripple::TxQ::Setup::normalConsensusIncreasePercent
std::uint32_t normalConsensusIncreasePercent
When the ledger has more transactions than "expected", and performance is humming along nicely,...
Definition: TxQ.h:128
ripple::TxQ::MaybeTx::byFeeListHook
boost::intrusive::set_member_hook byFeeListHook
Used by the TxQ::FeeHook and TxQ::FeeMultiSet below to put each MaybeTx object into more than one set...
Definition: TxQ.h:515
ripple::TxQ::TxQAccount::retryPenalty
bool retryPenalty
Definition: TxQ.h:663
ripple::TxQ::MaybeTx::feeLevel
const FeeLevel64 feeLevel
Computed fee level that the transaction will pay.
Definition: TxQ.h:521
ripple::base_uint< 160, detail::AccountIDTag >
ripple::TxQ::Setup::targetTxnInLedger
std::uint32_t targetTxnInLedger
Number of transactions per ledger that fee escalation "works towards".
Definition: TxQ.h:105
ripple::toDrops
XRPAmount toDrops(FeeLevel< T > const &level, XRPAmount const &baseFee)
Definition: TxQ.h:840
ripple::TxQ::MaybeTx::MaybeTx
MaybeTx(std::shared_ptr< STTx const > const &, TxID const &txID, FeeLevel64 feeLevel, ApplyFlags const flags, PreflightResult const &pfresult)
Constructor.
Definition: TxQ.cpp:268
ripple::TxQ::Setup::standAlone
bool standAlone
Use standalone mode behavior.
Definition: TxQ.h:153
ripple::TxQ
Transaction Queue.
Definition: TxQ.h:56
ripple::TxQ::byFee_
FeeMultiSet byFee_
The queue itself: the collection of transactions ordered by fee level.
Definition: TxQ.h:757
ripple::PreflightResult
Describes the results of the preflight check.
Definition: applySteps.h:150
ripple::Config
Definition: Config.h:68
ripple::TxQ::TxDetails::account
AccountID account
The account the transaction is queued for.
Definition: TxQ.h:224
ripple::TxQ::feeMetrics_
FeeMetrics feeMetrics_
Tracks the current state of the queue.
Definition: TxQ.h:751
ripple::TxQ::Setup::minimumTxnInLedger
std::uint32_t minimumTxnInLedger
Minimum number of transactions to allow into the ledger before escalation, regardless of the prior le...
Definition: TxQ.h:99
ripple::TxQ::Setup
Structure used to customize TxQ behavior.
Definition: TxQ.h:65
ripple::TxQ::TxQAccount::account
const AccountID account
The account.
Definition: TxQ.h:653
ripple::TxQ::TxQAccount::getPrevTx
TxMap::const_iterator getPrevTx(SeqProxy seqProx) const
Find the entry in transactions that precedes seqProx, if one does.
Definition: TxQ.cpp:318
ripple::TERSubset
Definition: TER.h:327
ripple::TxQ::FeeMultiSet
boost::intrusive::multiset< MaybeTx, FeeHook, boost::intrusive::compare< OrderCandidates > > FeeMultiSet
Definition: TxQ.h:738
ripple::TxQ::TxQAccount::add
MaybeTx & add(MaybeTx &&)
Add a transaction candidate to this account for queuing.
Definition: TxQ.cpp:329
ripple::TxQ::getTxRequiredFeeAndSeq
FeeAndSeq getTxRequiredFeeAndSeq(OpenView const &view, std::shared_ptr< STTx const > const &tx) const
Returns minimum required fee for tx and two sequences: first vaild sequence for this account in curre...
Definition: TxQ.cpp:1722
ripple::TxQ::MaybeTx::pfresult
std::optional< PreflightResult const > pfresult
Cached result of the preflight operation.
Definition: TxQ.h:560
ripple::TxQ::nextQueuableSeq
SeqProxy nextQueuableSeq(std::shared_ptr< SLE const > const &sleAccount) const
Return the next sequence that would go in the TxQ for an account.
Definition: TxQ.cpp:1539
ripple::TxQ::MaybeTx
Represents a transaction in the queue which may be applied later to the open ledger.
Definition: TxQ.h:509
ripple::TxQ::TxDetails::retriesRemaining
int retriesRemaining
Number of times the transactor can return a retry / ter result when attempting to apply this transact...
Definition: TxQ.h:234
ripple::STTx
Definition: STTx.h:43
ripple::TxQ::Setup::slowConsensusDecreasePercent
std::uint32_t slowConsensusDecreasePercent
When consensus takes longer than appropriate, the expected ledger size is updated to the lesser of th...
Definition: TxQ.h:142
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::TxQ::baseLevel
static constexpr FeeLevel64 baseLevel
Fee level for single-signed reference transaction.
Definition: TxQ.h:60
std::uint32_t
ripple::TxQ::FeeMetrics::scaleFeeLevel
static FeeLevel64 scaleFeeLevel(Snapshot const &snapshot, OpenView const &view)
Use the number of transactions in the current open ledger to compute the fee level a transaction must...
Definition: TxQ.cpp:168
ripple::feeunit::TaggedFee
Definition: FeeUnits.h:70
std::map< SeqProxy, MaybeTx >
ripple::TxQ::FeeMetrics::minimumTxnCount_
const std::size_t minimumTxnCount_
Minimum value of txnsExpected.
Definition: TxQ.h:377
ripple::TxQ::FeeAndSeq::accountSeq
std::uint32_t accountSeq
Definition: TxQ.h:318
ripple::TxQ::processClosedLedger
void processClosedLedger(Application &app, ReadView const &view, bool timeLeap)
Update fee metrics and clean up the queue in preparation for the next ledger.
Definition: TxQ.cpp:1330
ripple::TxQ::MaybeTx::seqProxy
const SeqProxy seqProxy
Transaction SeqProxy number (sfSequence or sfTicketSequence field).
Definition: TxQ.h:531
ripple::TxQ::doRPC
Json::Value doRPC(Application &app) const
Summarize current fee metrics for the fee RPC command.
Definition: TxQ.cpp:1779
ripple::TxQ::FeeMetrics::targetTxnCount_
const std::size_t targetTxnCount_
Number of transactions per ledger that fee escalation "works towards".
Definition: TxQ.h:380
ripple::TxQ::MaybeTx::consequences
TxConsequences const & consequences() const
Potential TxConsequences of applying this transaction to the open ledger.
Definition: TxQ.h:594
ripple::TxQ::TxQAccount::dropPenalty
bool dropPenalty
Definition: TxQ.h:669
ripple::TxQ::Metrics::referenceFeeLevel
FeeLevel64 referenceFeeLevel
Reference transaction fee level.
Definition: TxQ.h:174
ripple::TxQ::TxDetails::consequences
TxConsequences consequences
Potential TxConsequences of applying the queued transaction to the open ledger.
Definition: TxQ.h:222
ripple::TxQ::~TxQ
virtual ~TxQ()
Destructor.
Definition: TxQ.cpp:353
ripple::TxQ::TxQAccount::empty
bool empty() const
Checks if this account has no transactions queued.
Definition: TxQ.h:686
ripple::TxQ::Metrics::medFeeLevel
FeeLevel64 medFeeLevel
Median fee level of the last ledger.
Definition: TxQ.h:179
ripple::TxQ::FeeMetrics::Snapshot
Snapshot of the externally relevant FeeMetrics fields at any given time.
Definition: TxQ.h:438
ripple::TxQ::FeeMetrics::Snapshot::escalationMultiplier
const FeeLevel64 escalationMultiplier
Definition: TxQ.h:446
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:192
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::TxQ::TxQ
TxQ(Setup const &setup, beast::Journal j)
Constructor.
Definition: TxQ.cpp:348
ripple::TxQ::TxQAccount::getTxnCount
std::size_t getTxnCount() const
Return the number of transactions currently queued for this account.
Definition: TxQ.h:679
ripple::TxQ::getRequiredFeeLevel
FeeLevel64 getRequiredFeeLevel(OpenView &view, ApplyFlags flags, FeeMetrics::Snapshot const &metricsSnapshot, std::lock_guard< std::mutex > const &lock) const
Definition: TxQ.cpp:1599
ripple::TxQ::MaybeTx::account
const AccountID account
Account submitting the transaction.
Definition: TxQ.h:525
ripple::TxQ::Setup::Setup
Setup()=default
Default constructor.
std
STL namespace.
ripple::TxQ::Metrics::txInLedger
std::size_t txInLedger
Number of transactions currently in the open ledger.
Definition: TxQ.h:170
ripple::TxQ::mutex_
std::mutex mutex_
Most queue operations are done under the master lock, but use this mutex for the RPC "fee" command,...
Definition: TxQ.h:776
ripple::TxQ::maxSize_
std::optional< size_t > maxSize_
Maximum number of transactions allowed in the queue based on the current metrics.
Definition: TxQ.h:771
ripple::SeqProxy
A type that represents either a sequence value or a ticket value.
Definition: SeqProxy.h:55
ripple::TxQ::MaybeTx::retriesAllowed
static constexpr int retriesAllowed
Starting retry count for newly queued transactions.
Definition: TxQ.h:576
ripple::TxQ::FeeMetrics::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:394
ripple::TxQ::Metrics::txCount
std::size_t txCount
Number of transactions in the queue.
Definition: TxQ.h:166
ripple::TxQ::TxDetails::TxDetails
TxDetails(FeeLevel64 feeLevel_, std::optional< LedgerIndex > const &lastValid_, TxConsequences const &consequences_, AccountID const &account_, SeqProxy seqProxy_, std::shared_ptr< STTx const > const &txn_, int retriesRemaining_, TER preflightResult_, std::optional< TER > lastResult_)
Full initialization.
Definition: TxQ.h:193
ripple::TxQ::Setup::retrySequencePercent
std::uint32_t retrySequencePercent
Extra percentage required on the fee level of a queued transaction to replace that transaction with a...
Definition: TxQ.h:93
optional
std::mutex
STL class.
ripple::TxQ::Setup::minimumTxnInLedgerSA
std::uint32_t minimumTxnInLedgerSA
Like minimumTxnInLedger for standalone mode.
Definition: TxQ.h:102
std::size_t
ripple::TxQ::TxDetails::preflightResult
TER preflightResult
The intermediate result returned by preflight before this transaction was queued, or after it is queu...
Definition: TxQ.h:244
ripple::TxQ::OrderCandidates
Used for sorting MaybeTx.
Definition: TxQ.h:617
ripple::TxQ::TxQAccount::TxQAccount
TxQAccount(std::shared_ptr< STTx const > const &txn)
Construct from a transaction.
Definition: TxQ.cpp:308
ripple::mulDiv
std::pair< bool, Dest > mulDiv(Source1 value, Dest mul, Source2 div)
Definition: FeeUnits.h:473
ripple::TxQ::tryDirectApply
std::optional< std::pair< TER, bool > > tryDirectApply(Application &app, OpenView &view, std::shared_ptr< STTx const > const &tx, ApplyFlags flags, beast::Journal j)
Definition: TxQ.cpp:1609
ripple::TxQ::TxDetails::feeLevel
FeeLevel64 feeLevel
Fee level of the queued transaction.
Definition: TxQ.h:216
ripple::STAmount::cMaxNativeN
static const std::uint64_t cMaxNativeN
Definition: STAmount.h:69
ripple::TxQ::Setup::maximumTxnInLedger
std::optional< std::uint32_t > maximumTxnInLedger
Optional maximum allowed value of transactions per ledger before fee escalation kicks in.
Definition: TxQ.h:116
ripple::TxQ::Metrics::openLedgerFeeLevel
FeeLevel64 openLedgerFeeLevel
Minimum fee level to get into the current open ledger, bypassing the queue.
Definition: TxQ.h:182
ripple::TxQ::Metrics::txQMaxSize
std::optional< std::size_t > txQMaxSize
Max transactions currently allowed in queue.
Definition: TxQ.h:168
ripple::TxQ::Setup::queueSizeMin
std::size_t queueSizeMin
The smallest limit the queue is allowed.
Definition: TxQ.h:83
ripple::TxQ::getAccountTxs
std::vector< TxDetails > getAccountTxs(AccountID const &account, ReadView const &view) const
Returns information about the transactions currently in the queue for the account.
Definition: TxQ.cpp:1743
ripple::TxQ::byAccount_
AccountMap byAccount_
All of the accounts which currently have any transactions in the queue.
Definition: TxQ.h:764
ripple::TxQ::getMetrics
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
Definition: TxQ.cpp:1700
ripple::TxQ::FeeMetrics::txnsExpected_
std::size_t txnsExpected_
Number of transactions expected per ledger.
Definition: TxQ.h:386
ripple::TxQ::Setup::minimumEscalationMultiplier
FeeLevel64 minimumEscalationMultiplier
Minimum value of the escalation multiplier, regardless of the prior ledger's median fee level.
Definition: TxQ.h:96
ripple::TxQ::MaybeTx::retriesRemaining
int retriesRemaining
A transaction at the front of the queue will be given several attempts to succeed before being droppe...
Definition: TxQ.h:540
ripple::TxQ::OrderCandidates::operator()
bool operator()(const MaybeTx &lhs, const MaybeTx &rhs) const
Sort MaybeTx by feeLevel descending, then by transaction ID ascending.
Definition: TxQ.h:636
ripple::TxQ::Setup::minimumLastLedgerBuffer
std::uint32_t minimumLastLedgerBuffer
Minimum difference between the current ledger sequence and a transaction's LastLedgerSequence for the...
Definition: TxQ.h:151
ripple::TxQ::MaybeTx::txID
const TxID txID
Transaction ID.
Definition: TxQ.h:523
ripple::TxQ::TxDetails::lastResult
std::optional< TER > lastResult
If the transactor attempted to apply the transaction to the open ledger from the queue and failed,...
Definition: TxQ.h:251
ripple::TxQ::FeeMetrics::escalatedSeriesFeeLevel
static std::pair< bool, FeeLevel64 > escalatedSeriesFeeLevel(Snapshot const &snapshot, OpenView const &view, std::size_t extraCount, std::size_t seriesSize)
Computes the total fee level for all transactions in a series.
Definition: TxQ.cpp:228
ripple::TxQ::Setup::ledgersInQueue
std::size_t ledgersInQueue
Number of ledgers' worth of transactions to allow in the queue.
Definition: TxQ.h:77
ripple::TxQ::MaybeTx::lastValid
const std::optional< LedgerIndex > lastValid
Expiration ledger for the transaction (sfLastLedgerSequence field).
Definition: TxQ.h:528
ripple::TxQ::FeeAndSeq::availableSeq
std::uint32_t availableSeq
Definition: TxQ.h:319
ripple::TxConsequences
Class describing the consequences to the account of applying a transaction if the transaction consume...
Definition: applySteps.h:45
std::numeric_limits
ripple::TxQ::FeeMetrics::Snapshot::txnsExpected
const std::size_t txnsExpected
Definition: TxQ.h:443
ripple::TxQ::TxDetails::txn
std::shared_ptr< STTx const > txn
The full transaction.
Definition: TxQ.h:228
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::TxQ::FeeAndSeq::fee
XRPAmount fee
Definition: TxQ.h:317
ripple::TxQ::Metrics::txPerLedger
std::size_t txPerLedger
Number of transactions expected per ledger.
Definition: TxQ.h:172