rippled
Loading...
Searching...
No Matches
TrustLine.h
1#pragma once
2
3#include <xrpl/basics/CountedObject.h>
4#include <xrpl/ledger/View.h>
5#include <xrpl/protocol/Rate.h>
6#include <xrpl/protocol/STAmount.h>
7#include <xrpl/protocol/STLedgerEntry.h>
8
9#include <cstdint>
10#include <optional>
11
12namespace xrpl {
13
21enum class LineDirection : bool { incoming = false, outgoing = true };
22
34{
35protected:
36 // This class should not be instantiated directly. Use one of the derived
37 // classes.
38 TrustLineBase(std::shared_ptr<SLE const> const& sle, AccountID const& viewAccount);
39
40 ~TrustLineBase() = default;
41 TrustLineBase(TrustLineBase const&) = default;
43 operator=(TrustLineBase const&) = delete;
45
46public:
48 uint256 const&
49 key() const
50 {
51 return key_;
52 }
53
54 // VFALCO Take off the "get" from each function name
55
56 AccountID const&
58 {
60 }
61
62 AccountID const&
64 {
66 }
67
68 // True, Provided auth to peer.
69 bool
70 getAuth() const
71 {
73 }
74
75 bool
77 {
79 }
80
81 bool
83 {
85 }
86
87 bool
89 {
91 }
92
98
104
106 bool
107 getFreeze() const
108 {
110 }
111
113 bool
115 {
117 }
118
120 bool
122 {
124 }
125
127 bool
132
133 STAmount const&
135 {
136 return mBalance;
137 }
138
139 STAmount const&
140 getLimit() const
141 {
143 }
144
145 STAmount const&
147 {
148 return !mViewLowest ? mLowLimit : mHighLimit;
149 }
150
152 getJson(int);
153
154protected:
156
159
161
163
165};
166
167// This wrapper is used for the path finder
168class PathFindTrustLine final : public TrustLineBase, public CountedObject<PathFindTrustLine>
169{
171
172public:
174
176 makeItem(AccountID const& accountID, std::shared_ptr<SLE const> const& sle);
177
179 getItems(AccountID const& accountID, ReadView const& view, LineDirection direction);
180};
181
182// This wrapper is used for the `AccountLines` command and includes the quality
183// in and quality out values.
184class RPCTrustLine final : public TrustLineBase, public CountedObject<RPCTrustLine>
185{
187
188public:
189 RPCTrustLine() = delete;
190
191 RPCTrustLine(std::shared_ptr<SLE const> const& sle, AccountID const& viewAccount);
192
193 Rate const&
195 {
197 }
198
199 Rate const&
201 {
203 }
204
206 makeItem(AccountID const& accountID, std::shared_ptr<SLE const> const& sle);
207
209 getItems(AccountID const& accountID, ReadView const& view);
210
211private:
216};
217
218} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Tracks the number of instances of an object.
static std::vector< PathFindTrustLine > getItems(AccountID const &accountID, ReadView const &view, LineDirection direction)
Definition TrustLine.cpp:58
static std::optional< PathFindTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
Definition TrustLine.cpp:31
static std::vector< RPCTrustLine > getItems(AccountID const &accountID, ReadView const &view)
Definition TrustLine.cpp:81
static std::optional< RPCTrustLine > makeItem(AccountID const &accountID, std::shared_ptr< SLE const > const &sle)
Definition TrustLine.cpp:73
Rate const & getQualityIn() const
Definition TrustLine.h:194
Rate const & getQualityOut() const
Definition TrustLine.h:200
A view into a ledger.
Definition ReadView.h:31
AccountID const & getIssuer() const
Definition STAmount.h:466
Wraps a trust line SLE for convenience.
Definition TrustLine.h:34
AccountID const & getAccountIDPeer() const
Definition TrustLine.h:63
bool getNoRipplePeer() const
Definition TrustLine.h:88
TrustLineBase(TrustLineBase &&)=default
STAmount const mHighLimit
Definition TrustLine.h:158
bool getAuth() const
Definition TrustLine.h:70
STAmount const & getLimit() const
Definition TrustLine.h:140
std::uint32_t mFlags
Definition TrustLine.h:162
bool getDeepFreeze() const
Have we set the deep freeze flag on our peer.
Definition TrustLine.h:114
Json::Value getJson(int)
Definition TrustLine.cpp:22
LineDirection getDirection() const
Definition TrustLine.h:94
uint256 const & key() const
Returns the state map key for the ledger entry.
Definition TrustLine.h:49
AccountID const & getAccountID() const
Definition TrustLine.h:57
bool getFreezePeer() const
Has the peer set the freeze flag on us.
Definition TrustLine.h:121
bool getDeepFreezePeer() const
Has the peer set the deep freeze flag on us.
Definition TrustLine.h:128
STAmount const & getLimitPeer() const
Definition TrustLine.h:146
TrustLineBase(std::shared_ptr< SLE const > const &sle, AccountID const &viewAccount)
Definition TrustLine.cpp:9
bool getFreeze() const
Have we set the freeze flag on our peer.
Definition TrustLine.h:107
bool getAuthPeer() const
Definition TrustLine.h:76
~TrustLineBase()=default
STAmount const & getBalance() const
Definition TrustLine.h:134
TrustLineBase & operator=(TrustLineBase const &)=delete
STAmount const mLowLimit
Definition TrustLine.h:157
LineDirection getDirectionPeer() const
Definition TrustLine.h:100
TrustLineBase(TrustLineBase const &)=default
bool getNoRipple() const
Definition TrustLine.h:82
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
LineDirection
Describes how an account was found in a path, and how to find the next set of paths.
Definition TrustLine.h:21
@ lsfLowDeepFreeze
@ lsfLowNoRipple
@ lsfLowFreeze
@ lsfHighFreeze
@ lsfHighNoRipple
@ lsfHighDeepFreeze
@ lsfHighAuth
Represents a transfer rate.
Definition Rate.h:20