xrpld
Loading...
Searching...
No Matches
RippleCalc.h
1#pragma once
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/core/ServiceRegistry.h>
5#include <xrpl/ledger/PaymentSandbox.h>
6#include <xrpl/protocol/AccountID.h>
7#include <xrpl/protocol/STAmount.h>
8#include <xrpl/protocol/STPathSet.h>
9#include <xrpl/protocol/TER.h>
10
11#include <boost/container/flat_set.hpp>
12
13#include <optional>
14
15namespace xrpl {
16class Config;
17namespace path {
18
19namespace detail {
20struct FlowDebugInfo;
21} // namespace detail
22
30{
31public:
32 struct Input
33 {
34 explicit Input() = default;
35
38 bool limitQuality = false;
39 bool isLedgerOpen = true;
40 };
41 struct Output
42 {
43 explicit Output() = default;
44
45 // The computed input amount.
47
48 // The computed output amount.
50
51 // Collection of offers found expired or unfunded. When a payment
52 // succeeds, unfunded and expired offers are removed. When a payment
53 // fails, they are not removed. This vector contains the offers that
54 // could have been removed but were not because the payment fails. It is
55 // useful for offer crossing, which does remove the offers.
56 boost::container::flat_set<uint256> removableOffers;
57
58 private:
60
61 public:
62 [[nodiscard]] TER
63 result() const
64 {
65 return calculationResult_;
66 }
67 void
68 setResult(TER const value)
69 {
70 calculationResult_ = value;
71 }
72 };
73
74 static Output
77
78 // Compute paths using this ledger entry set. Up to caller to actually
79 // apply to ledger.
80
81 // Issuer:
82 // XRP: xrpAccount()
83 // non-XRP: uSrcAccountID (for any issuer) or another account with
84 // trust node.
85 STAmount const& saMaxAmountReq, // --> -1 = no limit.
86
87 // Issuer:
88 // XRP: xrpAccount()
89 // non-XRP: uDstAccountID (for any issuer) or another account with
90 // trust node.
91 STAmount const& saDstAmountReq,
92
93 AccountID const& uDstAccountID,
94 AccountID const& uSrcAccountID,
95
96 // A set of paths that are included in the transaction that we'll
97 // explore for liquidity.
98 STPathSet const& spsPaths,
99
100 std::optional<uint256> const& domainID,
101 ServiceRegistry& registry,
102 Input const* const pInputs = nullptr);
103
104 // The view we are currently working on
106
107 // If the transaction fails to meet some constraint, still need to delete
108 // unfunded offers in a deterministic order (hence the ordered container).
109 //
110 // Offers that were found unfunded.
111 boost::container::flat_set<uint256> permanentlyUnfundedOffers;
112};
113
114} // namespace path
115} // namespace xrpl
A wrapper which makes credits unavailable to balances.
Service registry for dependency injection.
RippleCalc calculates the quality of a payment path.
Definition RippleCalc.h:30
static Output rippleCalculate(PaymentSandbox &view, STAmount const &saMaxAmountReq, STAmount const &saDstAmountReq, AccountID const &uDstAccountID, AccountID const &uSrcAccountID, STPathSet const &spsPaths, std::optional< uint256 > const &domainID, ServiceRegistry &registry, Input const *const pInputs=nullptr)
boost::container::flat_set< uint256 > permanentlyUnfundedOffers
Definition RippleCalc.h:111
PaymentSandbox & view
Definition RippleCalc.h:105
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:34
@ temUNKNOWN
Definition TER.h:112
TERSubset< CanCvtToTER > TER
Definition TER.h:647
void setResult(TER const value)
Definition RippleCalc.h:68
boost::container::flat_set< uint256 > removableOffers
Definition RippleCalc.h:56