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
26{
27public:
28 struct Input
29 {
30 explicit Input() = default;
31
34 bool limitQuality = false;
35 bool isLedgerOpen = true;
36 };
37 struct Output
38 {
39 explicit Output() = default;
40
41 // The computed input amount.
43
44 // The computed output amount.
46
47 // Collection of offers found expired or unfunded. When a payment
48 // succeeds, unfunded and expired offers are removed. When a payment
49 // fails, they are not removed. This vector contains the offers that
50 // could have been removed but were not because the payment fails. It is
51 // useful for offer crossing, which does remove the offers.
52 boost::container::flat_set<UInt256> removableOffers;
53
54 private:
56
57 public:
58 [[nodiscard]] TER
59 result() const
60 {
61 return calculationResult_;
62 }
63 void
64 setResult(TER const value)
65 {
66 calculationResult_ = value;
67 }
68 };
69
70 static Output
73
74 // Compute paths using this ledger entry set. Up to caller to actually
75 // apply to ledger.
76
77 // Issuer:
78 // XRP: xrpAccount()
79 // non-XRP: uSrcAccountID (for any issuer) or another account with
80 // trust node.
81 STAmount const& saMaxAmountReq, // --> -1 = no limit.
82
83 // Issuer:
84 // XRP: xrpAccount()
85 // non-XRP: uDstAccountID (for any issuer) or another account with
86 // trust node.
87 STAmount const& saDstAmountReq,
88
89 AccountID const& uDstAccountID,
90 AccountID const& uSrcAccountID,
91
92 // A set of paths that are included in the transaction that we'll
93 // explore for liquidity.
94 STPathSet const& spsPaths,
95
96 std::optional<UInt256> const& domainID,
97 ServiceRegistry& registry,
98 Input const* const pInputs = nullptr);
99
100 // The view we are currently working on
102
103 // If the transaction fails to meet some constraint, still need to delete
104 // unfunded offers in a deterministic order (hence the ordered container).
105 //
106 // Offers that were found unfunded.
107 boost::container::flat_set<UInt256> permanentlyUnfundedOffers;
108};
109
110} // namespace path
111} // 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:26
boost::container::flat_set< UInt256 > permanentlyUnfundedOffers
Definition RippleCalc.h:107
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)
PaymentSandbox & view
Definition RippleCalc.h:101
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:657
void setResult(TER const value)
Definition RippleCalc.h:64
boost::container::flat_set< UInt256 > removableOffers
Definition RippleCalc.h:52