rippled
Loading...
Searching...
No Matches
RippleCalc.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 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_APP_PATHS_RIPPLECALC_H_INCLUDED
21#define RIPPLE_APP_PATHS_RIPPLECALC_H_INCLUDED
22
23#include <xrpld/ledger/PaymentSandbox.h>
24
25#include <xrpl/basics/Log.h>
26#include <xrpl/protocol/STAmount.h>
27#include <xrpl/protocol/TER.h>
28
29#include <boost/container/flat_set.hpp>
30
31namespace ripple {
32class Config;
33namespace path {
34
35namespace detail {
36struct FlowDebugInfo;
37}
38
45{
46public:
47 struct Input
48 {
49 explicit Input() = default;
50
53 bool limitQuality = false;
54 bool isLedgerOpen = true;
55 };
56 struct Output
57 {
58 explicit Output() = default;
59
60 // The computed input amount.
62
63 // The computed output amount.
65
66 // Collection of offers found expired or unfunded. When a payment
67 // succeeds, unfunded and expired offers are removed. When a payment
68 // fails, they are not removed. This vector contains the offers that
69 // could have been removed but were not because the payment fails. It is
70 // useful for offer crossing, which does remove the offers.
71 boost::container::flat_set<uint256> removableOffers;
72
73 private:
75
76 public:
77 TER
78 result() const
79 {
80 return calculationResult_;
81 }
82 void
83 setResult(TER const value)
84 {
85 calculationResult_ = value;
86 }
87 };
88
89 static Output
92
93 // Compute paths using this ledger entry set. Up to caller to actually
94 // apply to ledger.
95
96 // Issuer:
97 // XRP: xrpAccount()
98 // non-XRP: uSrcAccountID (for any issuer) or another account with
99 // trust node.
100 STAmount const& saMaxAmountReq, // --> -1 = no limit.
101
102 // Issuer:
103 // XRP: xrpAccount()
104 // non-XRP: uDstAccountID (for any issuer) or another account with
105 // trust node.
106 STAmount const& saDstAmountReq,
107
108 AccountID const& uDstAccountID,
109 AccountID const& uSrcAccountID,
110
111 // A set of paths that are included in the transaction that we'll
112 // explore for liquidity.
113 STPathSet const& spsPaths,
114 Logs& l,
115 Input const* const pInputs = nullptr);
116
117 // The view we are currently working on
119
120 // If the transaction fails to meet some constraint, still need to delete
121 // unfunded offers in a deterministic order (hence the ordered container).
122 //
123 // Offers that were found unfunded.
124 boost::container::flat_set<uint256> permanentlyUnfundedOffers_;
125};
126
127} // namespace path
128} // namespace ripple
129
130#endif
Manages partitions for logging.
Definition: Log.h:51
A wrapper which makes credits unavailable to balances.
RippleCalc calculates the quality of a payment path.
Definition: RippleCalc.h:45
PaymentSandbox & view
Definition: RippleCalc.h:118
static Output rippleCalculate(PaymentSandbox &view, STAmount const &saMaxAmountReq, STAmount const &saDstAmountReq, AccountID const &uDstAccountID, AccountID const &uSrcAccountID, STPathSet const &spsPaths, Logs &l, Input const *const pInputs=nullptr)
Definition: RippleCalc.cpp:32
boost::container::flat_set< uint256 > permanentlyUnfundedOffers_
Definition: RippleCalc.h:124
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
@ temUNKNOWN
Definition: TER.h:124
boost::container::flat_set< uint256 > removableOffers
Definition: RippleCalc.h:71
void setResult(TER const value)
Definition: RippleCalc.h:83