xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
tx
paths
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
15
namespace
xrpl
{
16
class
Config
;
17
namespace
path
{
18
19
namespace
detail
{
20
struct
FlowDebugInfo
;
21
}
// namespace detail
22
29
class
RippleCalc
30
{
31
public
:
32
struct
Input
33
{
34
explicit
Input
() =
default
;
35
36
bool
partialPaymentAllowed
=
false
;
37
bool
defaultPathsAllowed
=
true
;
38
bool
limitQuality
=
false
;
39
bool
isLedgerOpen
=
true
;
40
};
41
struct
Output
42
{
43
explicit
Output
() =
default
;
44
45
// The computed input amount.
46
STAmount
actualAmountIn
;
47
48
// The computed output amount.
49
STAmount
actualAmountOut
;
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
:
59
TER
calculationResult_
=
temUNKNOWN
;
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
75
rippleCalculate
(
76
PaymentSandbox
&
view
,
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
105
PaymentSandbox
&
view
;
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
xrpl::Config
Definition
src/xrpld/core/Config.h:89
xrpl::PaymentSandbox
A wrapper which makes credits unavailable to balances.
Definition
PaymentSandbox.h:149
xrpl::STAmount
Definition
STAmount.h:46
xrpl::STPathSet
Definition
STPathSet.h:200
xrpl::ServiceRegistry
Service registry for dependency injection.
Definition
ServiceRegistry.h:98
xrpl::path::RippleCalc
RippleCalc calculates the quality of a payment path.
Definition
RippleCalc.h:30
xrpl::path::RippleCalc::permanentlyUnfundedOffers
boost::container::flat_set< UInt256 > permanentlyUnfundedOffers
Definition
RippleCalc.h:111
xrpl::path::RippleCalc::rippleCalculate
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 ®istry, Input const *const pInputs=nullptr)
Definition
RippleCalc.cpp:23
xrpl::path::RippleCalc::view
PaymentSandbox & view
Definition
RippleCalc.h:105
xrpl::path::detail
Definition
FlowDebugInfo.h:21
xrpl::path
Definition
FlowDebugInfo.h:21
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
xrpl::temUNKNOWN
@ temUNKNOWN
Definition
TER.h:112
xrpl::TER
TERSubset< CanCvtToTER > TER
Definition
TER.h:654
optional
xrpl::path::RippleCalc::Input::limitQuality
bool limitQuality
Definition
RippleCalc.h:38
xrpl::path::RippleCalc::Input::defaultPathsAllowed
bool defaultPathsAllowed
Definition
RippleCalc.h:37
xrpl::path::RippleCalc::Input::Input
Input()=default
xrpl::path::RippleCalc::Input::isLedgerOpen
bool isLedgerOpen
Definition
RippleCalc.h:39
xrpl::path::RippleCalc::Input::partialPaymentAllowed
bool partialPaymentAllowed
Definition
RippleCalc.h:36
xrpl::path::RippleCalc::Output::actualAmountOut
STAmount actualAmountOut
Definition
RippleCalc.h:49
xrpl::path::RippleCalc::Output::actualAmountIn
STAmount actualAmountIn
Definition
RippleCalc.h:46
xrpl::path::RippleCalc::Output::setResult
void setResult(TER const value)
Definition
RippleCalc.h:68
xrpl::path::RippleCalc::Output::result
TER result() const
Definition
RippleCalc.h:63
xrpl::path::RippleCalc::Output::Output
Output()=default
xrpl::path::RippleCalc::Output::calculationResult_
TER calculationResult_
Definition
RippleCalc.h:59
xrpl::path::RippleCalc::Output::removableOffers
boost::container::flat_set< UInt256 > removableOffers
Definition
RippleCalc.h:56
xrpl::path::detail::FlowDebugInfo
Definition
FlowDebugInfo.h:24
Generated by
1.17.0