rippled
Loading...
Searching...
No Matches
TrustLine.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_RIPPLESTATE_H_INCLUDED
21#define RIPPLE_APP_PATHS_RIPPLESTATE_H_INCLUDED
22
23#include <xrpld/ledger/View.h>
24
25#include <xrpl/basics/CountedObject.h>
26#include <xrpl/protocol/Rate.h>
27#include <xrpl/protocol/STAmount.h>
28#include <xrpl/protocol/STLedgerEntry.h>
29
30#include <cstdint>
31#include <optional>
32
33namespace ripple {
34
42enum class LineDirection : bool { incoming = false, outgoing = true };
43
55{
56protected:
57 // This class should not be instantiated directly. Use one of the derived
58 // classes.
61 AccountID const& viewAccount);
62
63 ~TrustLineBase() = default;
64 TrustLineBase(TrustLineBase const&) = default;
66 operator=(TrustLineBase const&) = delete;
68
69public:
71 uint256 const&
72 key() const
73 {
74 return key_;
75 }
76
77 // VFALCO Take off the "get" from each function name
78
79 AccountID const&
81 {
83 }
84
85 AccountID const&
87 {
89 }
90
91 // True, Provided auth to peer.
92 bool
93 getAuth() const
94 {
96 }
97
98 bool
100 {
102 }
103
104 bool
106 {
108 }
109
110 bool
112 {
114 }
115
122
129
131 bool
132 getFreeze() const
133 {
135 }
136
138 bool
140 {
142 }
143
145 bool
147 {
149 }
150
152 bool
157
158 STAmount const&
160 {
161 return mBalance;
162 }
163
164 STAmount const&
165 getLimit() const
166 {
168 }
169
170 STAmount const&
172 {
173 return !mViewLowest ? mLowLimit : mHighLimit;
174 }
175
177 getJson(int);
178
179protected:
181
184
186
188
190};
191
192// This wrapper is used for the path finder
193class PathFindTrustLine final : public TrustLineBase,
194 public CountedObject<PathFindTrustLine>
195{
197
198public:
200
202 makeItem(AccountID const& accountID, std::shared_ptr<SLE const> const& sle);
203
205 getItems(
206 AccountID const& accountID,
207 ReadView const& view,
208 LineDirection direction);
209};
210
211// This wrapper is used for the `AccountLines` command and includes the quality
212// in and quality out values.
213class RPCTrustLine final : public TrustLineBase,
214 public CountedObject<RPCTrustLine>
215{
217
218public:
219 RPCTrustLine() = delete;
220
223 AccountID const& viewAccount);
224
225 Rate const&
227 {
229 }
230
231 Rate const&
233 {
235 }
236
238 makeItem(AccountID const& accountID, std::shared_ptr<SLE const> const& sle);
239
241 getItems(AccountID const& accountID, ReadView const& view);
242
243private:
248};
249
250} // namespace ripple
251
252#endif
Represents a JSON value.
Definition json_value.h:149
Tracks the number of instances of an object.
static std::vector< PathFindTrustLine > getItems(AccountID const &accountID, ReadView const &view, LineDirection direction)
Definition TrustLine.cpp:89
static std::optional< PathFindTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
Definition TrustLine.cpp:52
Rate const & getQualityIn() const
Definition TrustLine.h:226
static std::optional< RPCTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
static std::vector< RPCTrustLine > getItems(AccountID const &accountID, ReadView const &view)
Rate const & getQualityOut() const
Definition TrustLine.h:232
A view into a ledger.
Definition ReadView.h:52
AccountID const & getIssuer() const
Definition STAmount.h:508
Wraps a trust line SLE for convenience.
Definition TrustLine.h:55
bool getDeepFreeze() const
Have we set the deep freeze flag on our peer.
Definition TrustLine.h:139
std::uint32_t mFlags
Definition TrustLine.h:187
STAmount const & getLimit() const
Definition TrustLine.h:165
STAmount const mLowLimit
Definition TrustLine.h:182
STAmount const & getBalance() const
Definition TrustLine.h:159
bool getAuthPeer() const
Definition TrustLine.h:99
TrustLineBase(std::shared_ptr< SLE const > const &sle, AccountID const &viewAccount)
Definition TrustLine.cpp:28
TrustLineBase(TrustLineBase &&)=default
AccountID const & getAccountID() const
Definition TrustLine.h:80
uint256 const & key() const
Returns the state map key for the ledger entry.
Definition TrustLine.h:72
STAmount const & getLimitPeer() const
Definition TrustLine.h:171
STAmount const mHighLimit
Definition TrustLine.h:183
bool getNoRipplePeer() const
Definition TrustLine.h:111
bool getNoRipple() const
Definition TrustLine.h:105
Json::Value getJson(int)
Definition TrustLine.cpp:43
bool getFreezePeer() const
Has the peer set the freeze flag on us.
Definition TrustLine.h:146
AccountID const & getAccountIDPeer() const
Definition TrustLine.h:86
bool getFreeze() const
Have we set the freeze flag on our peer.
Definition TrustLine.h:132
TrustLineBase(TrustLineBase const &)=default
LineDirection getDirectionPeer() const
Definition TrustLine.h:124
bool getAuth() const
Definition TrustLine.h:93
LineDirection getDirection() const
Definition TrustLine.h:117
bool getDeepFreezePeer() const
Has the peer set the deep freeze flag on us.
Definition TrustLine.h:153
TrustLineBase & operator=(TrustLineBase const &)=delete
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
@ lsfHighDeepFreeze
@ lsfHighNoRipple
@ lsfLowDeepFreeze
LineDirection
Describes how an account was found in a path, and how to find the next set of paths.
Definition TrustLine.h:42
Represents a transfer rate.
Definition Rate.h:40