rippled
TxQ.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012-14 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/TER.h>
28 #include <boost/circular_buffer.hpp>
29 #include <boost/intrusive/set.hpp>
30 
31 namespace ripple {
32 
33 class Application;
34 class Config;
35 
54 class TxQ
55 {
56 public:
58  static constexpr FeeLevel64 baseLevel{256};
59 
63  struct Setup
64  {
66  explicit Setup() = default;
67 
127  boost::optional<std::uint32_t> maximumTxnInLedger;
173  bool standAlone = false;
174  };
175 
180  struct Metrics
181  {
183  explicit Metrics() = default;
184 
188  boost::optional<std::size_t> txQMaxSize;
203  };
204 
210  {
212  explicit AccountTxDetails() = default;
213 
217  boost::optional<LedgerIndex const> lastValid;
224  boost::optional<TxConsequences const> consequences;
225  };
226 
233  {
235  explicit TxDetails() = default;
236 
263  boost::optional<TER> lastResult;
264  };
265 
267  TxQ(Setup const& setup, beast::Journal j);
268 
270  virtual ~TxQ();
271 
282  apply(
283  Application& app,
284  OpenView& view,
285  std::shared_ptr<STTx const> const& tx,
286  ApplyFlags flags,
287  beast::Journal j);
288 
300  bool
301  accept(Application& app, OpenView& view);
302 
315  void
316  processClosedLedger(Application& app, ReadView const& view, bool timeLeap);
317 
320  Metrics
321  getMetrics(OpenView const& view) const;
322 
323  struct FeeAndSeq
324  {
328  };
329 
339  FeeAndSeq
341  OpenView const& view,
342  std::shared_ptr<STTx const> const& tx) const;
343 
351  getAccountTxs(AccountID const& account, ReadView const& view) const;
352 
360  getTxs(ReadView const& view) const;
361 
367  doRPC(Application& app) const;
368 
369 private:
376  {
377  private:
384  boost::optional<std::size_t> const maximumTxnCount_;
391  boost::circular_buffer<std::size_t> recentTxnCounts_;
397 
398  public:
400  FeeMetrics(Setup const& setup, beast::Journal j)
402  setup.standAlone ? setup.minimumTxnInLedgerSA
403  : setup.minimumTxnInLedger)
404  , targetTxnCount_(
405  setup.targetTxnInLedger < minimumTxnCount_
407  : setup.targetTxnInLedger)
409  setup.maximumTxnInLedger
410  ? *setup.maximumTxnInLedger < targetTxnCount_
412  : *setup.maximumTxnInLedger
413  : boost::optional<std::size_t>(boost::none))
415  , recentTxnCounts_(setup.ledgersInQueue)
416  , escalationMultiplier_(setup.minimumEscalationMultiplier)
417  , j_(j)
418  {
419  }
420 
432  update(
433  Application& app,
434  ReadView const& view,
435  bool timeLeap,
436  TxQ::Setup const& setup);
437 
440  struct Snapshot
441  {
442  // Number of transactions expected per ledger.
443  // One more than this value will be accepted
444  // before escalation kicks in.
446  // Based on the median fee of the LCL. Used
447  // when fee escalation kicks in.
449  };
450 
452  Snapshot
453  getSnapshot() const
454  {
456  }
457 
466  static FeeLevel64
467  scaleFeeLevel(Snapshot const& snapshot, OpenView const& view);
468 
501  Snapshot const& snapshot,
502  OpenView const& view,
503  std::size_t extraCount,
504  std::size_t seriesSize);
505  };
506 
511  class MaybeTx
512  {
513  public:
517  boost::intrusive::set_member_hook<> byFeeListHook;
518 
521 
524  boost::optional<TxConsequences const> consequences;
525 
529  TxID const txID;
531  boost::optional<TxID> priorTxID;
536  boost::optional<LedgerIndex> lastValid;
558  boost::optional<TER> lastResult;
567  boost::optional<PreflightResult const> pfresult;
568 
583  static constexpr int retriesAllowed = 10;
584 
585  public:
587  MaybeTx(
589  TxID const& txID,
591  ApplyFlags const flags,
592  PreflightResult const& pfresult);
593 
596  apply(Application& app, OpenView& view, beast::Journal j);
597  };
598 
601  {
602  public:
604  explicit GreaterFee() = default;
605 
607  bool
608  operator()(const MaybeTx& lhs, const MaybeTx& rhs) const
609  {
610  return lhs.feeLevel > rhs.feeLevel;
611  }
612  };
613 
618  {
619  public:
621 
626  /* If this account has had any transaction retry more than
627  `retriesAllowed` times so that it was dropped from the
628  queue, then all other transactions for this account will
629  be given at most 2 attempts before being removed. Helps
630  prevent wasting resources on retries that are more likely
631  to fail.
632  */
633  bool retryPenalty = false;
634  /* If this account has had any transaction fail or expire,
635  then when the queue is nearly full, transactions from
636  this account will be discarded. Helps prevent the queue
637  from getting filled and wedged.
638  */
639  bool dropPenalty = false;
640 
641  public:
643  explicit TxQAccount(std::shared_ptr<STTx const> const& txn);
645  explicit TxQAccount(const AccountID& account);
646 
649  getTxnCount() const
650  {
651  return transactions.size();
652  }
653 
655  bool
656  empty() const
657  {
658  return !getTxnCount();
659  }
660 
662  MaybeTx&
663  add(MaybeTx&&);
664 
670  bool
671  remove(TxSeq const& sequence);
672  };
673 
674  using FeeHook = boost::intrusive::member_hook<
675  MaybeTx,
676  boost::intrusive::set_member_hook<>,
678 
679  using FeeMultiSet = boost::intrusive::
680  multiset<MaybeTx, FeeHook, boost::intrusive::compare<GreaterFee>>;
681 
683 
685  Setup const setup_;
688 
713  boost::optional<size_t> maxSize_;
714 
719 
720 private:
722  template <size_t fillPercentage = 100>
723  bool
724  isFull() const;
725 
729  bool
730  canBeHeld(
731  STTx const&,
732  ApplyFlags const,
733  OpenView const&,
734  AccountMap::iterator,
735  boost::optional<FeeMultiSet::iterator>);
736 
738  FeeMultiSet::iterator_type erase(FeeMultiSet::const_iterator_type);
743  FeeMultiSet::iterator_type eraseAndAdvance(
744  FeeMultiSet::const_iterator_type);
746  TxQAccount::TxMap::iterator
747  erase(
748  TxQAccount& txQAccount,
749  TxQAccount::TxMap::const_iterator begin,
750  TxQAccount::TxMap::const_iterator end);
751 
758  Application& app,
759  OpenView& view,
760  STTx const& tx,
761  AccountMap::iterator const& accountIter,
762  TxQAccount::TxMap::iterator,
763  FeeLevel64 feeLevelPaid,
764  PreflightResult const& pfresult,
765  std::size_t const txExtraCount,
766  ApplyFlags flags,
767  FeeMetrics::Snapshot const& metricsSnapshot,
768  beast::Journal j);
769 };
770 
775 setup_TxQ(Config const&);
776 
777 template <class T>
779 toDrops(FeeLevel<T> const& level, XRPAmount const& baseFee)
780 {
781  return mulDiv(level, baseFee, TxQ::baseLevel);
782 }
783 
785 toFeeLevel(XRPAmount const& drops, XRPAmount const& baseFee)
786 {
787  return mulDiv(drops, TxQ::baseLevel, baseFee);
788 }
789 
790 } // namespace ripple
791 
792 #endif
ripple::TxQ::TxDetails::lastResult
boost::optional< TER > lastResult
If the transactor attempted to apply the transaction to the open ledger from the queue and failed,...
Definition: TxQ.h:263
ripple::TxQ::setup_
const Setup setup_
Setup parameters used to control the behavior of the queue.
Definition: TxQ.h:685
ripple::setup_TxQ
TxQ::Setup setup_TxQ(Config const &config)
Build a TxQ::Setup object from application configuration.
Definition: TxQ.cpp:1481
ripple::TxQ::Metrics::Metrics
Metrics()=default
Default constructor.
ripple::Application
Definition: Application.h:97
ripple::TxQ::MaybeTx::sequence
const TxSeq sequence
Transaction sequence number (sfSequence field).
Definition: TxQ.h:538
ripple::TxQ::FeeMetrics::maximumTxnCount_
const boost::optional< std::size_t > maximumTxnCount_
Maximum value of txnsExpected.
Definition: TxQ.h:384
ripple::TxQ::MaybeTx::consequences
boost::optional< TxConsequences const > consequences
Potential TxConsequences of applying this transaction to the open ledger.
Definition: TxQ.h:524
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:197
std::shared_ptr
STL class.
ripple::TxQ::MaybeTx::lastResult
boost::optional< TER > lastResult
If the transactor attempted to apply the transaction to the open ledger from the queue and failed,...
Definition: TxQ.h:558
ripple::TxQ::MaybeTx::txn
std::shared_ptr< STTx const > txn
The complete transaction.
Definition: TxQ.h:520
ripple::TxQ::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:687
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:597
ripple::TxQ::FeeMetrics::FeeMetrics
FeeMetrics(Setup const &setup, beast::Journal j)
Constructor.
Definition: TxQ.h:400
ripple::OpenView
Writable ledger view that accumulates state and tx changes.
Definition: OpenView.h:52
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:617
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:409
ripple::CashFilter::none
@ none
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:375
ripple::ApplyFlags
ApplyFlags
Definition: ApplyView.h:30
ripple::TxQ::Metrics::txQMaxSize
boost::optional< std::size_t > txQMaxSize
Max transactions currently allowed in queue.
Definition: TxQ.h:188
ripple::TxQ::FeeMetrics::getSnapshot
Snapshot getSnapshot() const
Get the current Snapshot.
Definition: TxQ.h:453
ripple::TxQ::FeeMultiSet
boost::intrusive::multiset< MaybeTx, FeeHook, boost::intrusive::compare< GreaterFee > > FeeMultiSet
Definition: TxQ.h:680
ripple::TxQ::TxDetails
Structure that describes a transaction in the queue waiting to be applied to the current open ledger.
Definition: TxQ.h:232
ripple::TxQ::MaybeTx::flags
const ApplyFlags flags
Flags provided to apply.
Definition: TxQ.h:551
ripple::TxQ::FeeMetrics::escalationMultiplier_
FeeLevel64 escalationMultiplier_
Based on the median fee of the LCL.
Definition: TxQ.h:394
ripple::TxQ::isFull
bool isFull() const
Is the queue at least fillPercentage full?
Definition: TxQ.cpp:325
ripple::TxQ::FeeAndSeq
Definition: TxQ.h:323
boost
Definition: IPAddress.h:117
ripple::TxQ::FeeMetrics::recentTxnCounts_
boost::circular_buffer< std::size_t > recentTxnCounts_
Recent history of transaction counts that exceed the targetTxnCount_.
Definition: TxQ.h:391
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:265
ripple::TxQ::TxQAccount::transactions
TxMap transactions
Sequence number will be used as the key.
Definition: TxQ.h:625
ripple::TxQ::Metrics
Structure returned by TxQ::getMetrics, expressed in reference fee level units.
Definition: TxQ.h:180
ripple::TxQ::MaybeTx::priorTxID
boost::optional< TxID > priorTxID
Prior transaction ID (sfAccountTxnID field).
Definition: TxQ.h:531
ripple::TxQ::accept
bool accept(Application &app, OpenView &view)
Fill the new open ledger with transactions from the queue.
Definition: TxQ.cpp:1199
ripple::TxQ::Setup::maximumTxnPerAccount
std::uint32_t maximumTxnPerAccount
Maximum number of transactions that can be queued by one account.
Definition: TxQ.h:155
ripple::TxQ::FeeHook
boost::intrusive::member_hook< MaybeTx, boost::intrusive::set_member_hook<>, &MaybeTx::byFeeListHook > FeeHook
Definition: TxQ.h:677
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:75
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:139
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:517
ripple::TxQ::Setup::maximumTxnInLedger
boost::optional< std::uint32_t > maximumTxnInLedger
Optional maximum allowed value of transactions per ledger before fee escalation kicks in.
Definition: TxQ.h:127
ripple::TxQ::TxQAccount::retryPenalty
bool retryPenalty
Definition: TxQ.h:633
ripple::TxQ::MaybeTx::feeLevel
const FeeLevel64 feeLevel
Computed fee level that the transaction will pay.
Definition: TxQ.h:527
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:116
ripple::TxQ::TxQAccount::remove
bool remove(TxSeq const &sequence)
Remove the candidate with given sequence number from this account.
Definition: TxQ.cpp:306
ripple::TxQ::TxDetails::TxDetails
TxDetails()=default
Default constructor.
ripple::TxQ::AccountTxDetails::consequences
boost::optional< TxConsequences const > consequences
Potential TxConsequences of applying the queued transaction to the open ledger, if known.
Definition: TxQ.h:224
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:243
ripple::TxQ::Setup::standAlone
bool standAlone
Use standalone mode behavior.
Definition: TxQ.h:173
ripple::TxQ
Transaction Queue.
Definition: TxQ.h:54
ripple::TxQ::byFee_
FeeMultiSet byFee_
The queue itself: the collection of transactions ordered by fee level.
Definition: TxQ.h:699
ripple::PreflightResult
Describes the results of the preflight check.
Definition: applySteps.h:46
ripple::TxQ::GreaterFee
Used for sorting MaybeTx by feeLevel
Definition: TxQ.h:600
ripple::Config
Definition: Config.h:67
ripple::TxQ::TxDetails::account
AccountID account
The account the transaction is queued for.
Definition: TxQ.h:238
ripple::TxQ::feeMetrics_
FeeMetrics feeMetrics_
Tracks the current state of the queue.
Definition: TxQ.h:693
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:110
ripple::TxQ::Setup
Structure used to customize TxQ behavior.
Definition: TxQ.h:63
ripple::TxQ::TxQAccount::account
const AccountID account
The account.
Definition: TxQ.h:623
ripple::TxQ::getTxs
std::vector< TxDetails > getTxs(ReadView const &view) const
Returns information about all transactions currently in the queue.
Definition: TxQ.cpp:1401
ripple::TERSubset< CanCvtToTER >
ripple::TxQ::AccountTxDetails::lastValid
boost::optional< LedgerIndex const > lastValid
LastValidLedger field of the queued transaction, if any.
Definition: TxQ.h:217
ripple::TxQ::GreaterFee::operator()
bool operator()(const MaybeTx &lhs, const MaybeTx &rhs) const
Is the fee level of lhs greater than the fee level of rhs?
Definition: TxQ.h:608
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:1336
ripple::TxQ::MaybeTx
Represents a transaction in the queue which may be applied later to the open ledger.
Definition: TxQ.h:511
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:246
ripple::STTx
Definition: STTx.h:42
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:153
ripple::TxQ::getAccountTxs
std::map< TxSeq, AccountTxDetails const > getAccountTxs(AccountID const &account, ReadView const &view) const
Returns information about the transactions currently in the queue for the account.
Definition: TxQ.cpp:1373
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:58
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:163
ripple::TxQ::TxQAccount::add
MaybeTx & add(MaybeTx &&)
Add a transaction candidate to this account for queuing.
Definition: TxQ.cpp:294
ripple::feeunit::TaggedFee
Definition: FeeUnits.h:70
std::map
STL class.
ripple::TxQ::FeeMetrics::minimumTxnCount_
const std::size_t minimumTxnCount_
Minimum value of txnsExpected.
Definition: TxQ.h:379
ripple::TxQ::FeeAndSeq::accountSeq
std::uint32_t accountSeq
Definition: TxQ.h:326
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:1130
ripple::TxQ::doRPC
Json::Value doRPC(Application &app) const
Summarize current fee metrics for the fee RPC command.
Definition: TxQ.cpp:1434
ripple::TxQ::FeeMetrics::targetTxnCount_
const std::size_t targetTxnCount_
Number of transactions per ledger that fee escalation "works towards".
Definition: TxQ.h:382
ripple::TxQ::MaybeTx::pfresult
boost::optional< PreflightResult const > pfresult
Cached result of the preflight operation.
Definition: TxQ.h:567
ripple::TxQ::Setup::zeroBaseFeeTransactionFeeLevel
FeeLevel64 zeroBaseFeeTransactionFeeLevel
So we don't deal with "infinite" fee levels, treat any transaction with a 0 base fee (i....
Definition: TxQ.h:171
ripple::TxQ::TxQAccount::dropPenalty
bool dropPenalty
Definition: TxQ.h:639
ripple::TxQ::Metrics::referenceFeeLevel
FeeLevel64 referenceFeeLevel
Reference transaction fee level.
Definition: TxQ.h:194
ripple::TxQ::AccountTxDetails
Structure returned by TxQ::getAccountTxs to describe transactions in the queue for an account.
Definition: TxQ.h:209
ripple::TxQ::~TxQ
virtual ~TxQ()
Destructor.
Definition: TxQ.cpp:318
ripple::TxQ::TxQAccount::empty
bool empty() const
Checks if this account has no transactions queued.
Definition: TxQ.h:656
ripple::TxQ::Metrics::medFeeLevel
FeeLevel64 medFeeLevel
Median fee level of the last ledger.
Definition: TxQ.h:199
ripple::TxQ::FeeMetrics::Snapshot
Snapshot of the externally relevant FeeMetrics fields at any given time.
Definition: TxQ.h:440
ripple::TxQ::FeeMetrics::Snapshot::escalationMultiplier
const FeeLevel64 escalationMultiplier
Definition: TxQ.h:448
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:188
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:313
ripple::TxQ::TxQAccount::getTxnCount
std::size_t getTxnCount() const
Return the number of transactions currently queued for this account.
Definition: TxQ.h:649
ripple::TxQ::maxSize_
boost::optional< size_t > maxSize_
Maximum number of transactions allowed in the queue based on the current metrics.
Definition: TxQ.h:713
ripple::TxQ::MaybeTx::account
const AccountID account
Account submitting the transaction.
Definition: TxQ.h:533
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:190
ripple::TxQ::GreaterFee::GreaterFee
GreaterFee()=default
Default constructor.
ripple::toFeeLevel
std::pair< bool, FeeLevel64 > toFeeLevel(XRPAmount const &drops, XRPAmount const &baseFee)
Definition: TxQ.h:785
ripple::toDrops
std::pair< bool, XRPAmount > toDrops(FeeLevel< T > const &level, XRPAmount const &baseFee)
Definition: TxQ.h:779
ripple::TxQ::canBeHeld
bool canBeHeld(STTx const &, ApplyFlags const, OpenView const &, AccountMap::iterator, boost::optional< FeeMultiSet::iterator >)
Checks if the indicated transaction fits the conditions for being stored in the queue.
Definition: TxQ.cpp:333
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:718
ripple::TxQ::MaybeTx::retriesAllowed
static constexpr int retriesAllowed
Starting retry count for newly queued transactions.
Definition: TxQ.h:583
ripple::TxQ::FeeMetrics::j_
const beast::Journal j_
Journal.
Definition: TxQ.h:396
ripple::TxQ::Metrics::txCount
std::size_t txCount
Number of transactions in the queue.
Definition: TxQ.h:186
ripple::TxQ::tryClearAccountQueue
std::pair< TER, bool > tryClearAccountQueue(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 all the queued txs for accountIter up to and including tx.
Definition: TxQ.cpp:458
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:91
ripple::TxQ::MaybeTx::lastValid
boost::optional< LedgerIndex > lastValid
Expiration ledger for the transaction (sfLastLedgerSequence field).
Definition: TxQ.h:536
std::mutex
STL class.
ripple::TxQ::Setup::minimumTxnInLedgerSA
std::uint32_t minimumTxnInLedgerSA
Like minimumTxnInLedger for standalone mode.
Definition: TxQ.h:113
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:256
ripple::TxQ::TxQAccount::TxQAccount
TxQAccount(std::shared_ptr< STTx const > const &txn)
Construct from a transaction.
Definition: TxQ.cpp:284
ripple::mulDiv
std::pair< bool, Dest > mulDiv(Source1 value, Dest mul, Source2 div)
Definition: FeeUnits.h:473
ripple::TxQ::Setup::multiTxnPercent
std::int32_t multiTxnPercent
Extra percentage required on the fee level of a queued transaction to queue the transaction with the ...
Definition: TxQ.h:104
ripple::TxQ::Metrics::openLedgerFeeLevel
FeeLevel64 openLedgerFeeLevel
Minimum fee level to get into the current open ledger, bypassing the queue.
Definition: TxQ.h:202
ripple::TxQ::Setup::queueSizeMin
std::size_t queueSizeMin
The smallest limit the queue is allowed.
Definition: TxQ.h:81
ripple::TxQ::AccountTxDetails::feeLevel
FeeLevel64 feeLevel
Fee level of the queued transaction.
Definition: TxQ.h:215
ripple::TxQ::byAccount_
AccountMap byAccount_
All of the accounts which currently have any transactions in the queue.
Definition: TxQ.h:706
ripple::TxQ::getMetrics
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
Definition: TxQ.cpp:1314
ripple::TxQ::FeeMetrics::txnsExpected_
std::size_t txnsExpected_
Number of transactions expected per ledger.
Definition: TxQ.h:388
ripple::TxQ::Setup::minimumEscalationMultiplier
FeeLevel64 minimumEscalationMultiplier
Minimum value of the escalation multiplier, regardless of the prior ledger's median fee level.
Definition: TxQ.h:107
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:547
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:162
ripple::TxQ::MaybeTx::txID
const TxID txID
Transaction ID.
Definition: TxQ.h:529
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:203
ripple::TxQ::Setup::ledgersInQueue
std::size_t ledgersInQueue
Number of ledgers' worth of transactions to allow in the queue.
Definition: TxQ.h:75
ripple::TxQ::FeeAndSeq::availableSeq
std::uint32_t availableSeq
Definition: TxQ.h:327
ripple::TxQ::FeeMetrics::Snapshot::txnsExpected
const std::size_t txnsExpected
Definition: TxQ.h:445
ripple::TxQ::TxDetails::txn
std::shared_ptr< STTx const > txn
The full transaction.
Definition: TxQ.h:240
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::TxQ::AccountTxDetails::AccountTxDetails
AccountTxDetails()=default
Default constructor.
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::TxQ::FeeAndSeq::fee
XRPAmount fee
Definition: TxQ.h:325
ripple::TxQ::Metrics::txPerLedger
std::size_t txPerLedger
Number of transactions expected per ledger.
Definition: TxQ.h:192