rippled
RippleState.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 <ripple/ledger/View.h>
24 #include <ripple/protocol/Rate.h>
25 #include <ripple/protocol/STAmount.h>
26 #include <ripple/protocol/STLedgerEntry.h>
27 #include <cstdint>
28 #include <memory> // <memory>
29 
30 namespace ripple {
31 
38 // VFALCO TODO Rename to TrustLine
40 {
41 public:
42  // VFALCO Why is this shared_ptr?
44 
45 public:
46  RippleState() = delete;
47 
48  virtual ~RippleState() = default;
49 
51  makeItem(AccountID const& accountID, std::shared_ptr<SLE const> sle);
52 
53  // Must be public, for make_shared
54  RippleState(std::shared_ptr<SLE const>&& sle, AccountID const& viewAccount);
55 
57  uint256
58  key() const
59  {
60  return sle_->key();
61  }
62 
63  // VFALCO Take off the "get" from each function name
64 
65  AccountID const&
66  getAccountID() const
67  {
68  return mViewLowest ? mLowID : mHighID;
69  }
70 
71  AccountID const&
73  {
74  return !mViewLowest ? mLowID : mHighID;
75  }
76 
77  // True, Provided auth to peer.
78  bool
79  getAuth() const
80  {
82  }
83 
84  bool
85  getAuthPeer() const
86  {
87  return mFlags & (!mViewLowest ? lsfLowAuth : lsfHighAuth);
88  }
89 
90  bool
91  getNoRipple() const
92  {
94  }
95 
96  bool
98  {
100  }
101 
103  bool
104  getFreeze() const
105  {
107  }
108 
110  bool
112  {
114  }
115 
116  STAmount const&
117  getBalance() const
118  {
119  return mBalance;
120  }
121 
122  STAmount const&
123  getLimit() const
124  {
125  return mViewLowest ? mLowLimit : mHighLimit;
126  }
127 
128  STAmount const&
129  getLimitPeer() const
130  {
131  return !mViewLowest ? mLowLimit : mHighLimit;
132  }
133 
134  Rate const&
135  getQualityIn() const
136  {
138  }
139 
140  Rate const&
142  {
144  }
145 
147  getJson(int);
148 
149 private:
151 
153 
155 
158 
161 
166 
168 };
169 
171 getRippleStateItems(AccountID const& accountID, ReadView const& view);
172 
173 } // namespace ripple
174 
175 #endif
ripple::RippleState::lowQualityOut_
Rate lowQualityOut_
Definition: RippleState.h:163
ripple::RippleState
Wraps a trust line SLE for convenience.
Definition: RippleState.h:39
ripple::RippleState::getAuthPeer
bool getAuthPeer() const
Definition: RippleState.h:85
ripple::RippleState::getQualityIn
Rate const & getQualityIn() const
Definition: RippleState.h:135
std::shared_ptr
STL class.
ripple::Rate
Represents a transfer rate.
Definition: Rate.h:37
ripple::RippleState::getAccountID
AccountID const & getAccountID() const
Definition: RippleState.h:66
ripple::RippleState::getFreezePeer
bool getFreezePeer() const
Has the peer set the freeze flag on us.
Definition: RippleState.h:111
ripple::lsfLowAuth
@ lsfLowAuth
Definition: LedgerFormats.h:123
ripple::lsfLowNoRipple
@ lsfLowNoRipple
Definition: LedgerFormats.h:125
ripple::RippleState::highQualityOut_
Rate highQualityOut_
Definition: RippleState.h:165
std::vector
STL class.
ripple::RippleState::mLowID
AccountID const & mLowID
Definition: RippleState.h:159
ripple::RippleState::getAuth
bool getAuth() const
Definition: RippleState.h:79
ripple::lsfHighAuth
@ lsfHighAuth
Definition: LedgerFormats.h:124
ripple::RippleState::highQualityIn_
Rate highQualityIn_
Definition: RippleState.h:164
ripple::getRippleStateItems
std::vector< RippleState::pointer > getRippleStateItems(AccountID const &accountID, ReadView const &view)
Definition: RippleState.cpp:70
ripple::base_uint< 160, detail::AccountIDTag >
ripple::RippleState::getLimit
STAmount const & getLimit() const
Definition: RippleState.h:123
ripple::RippleState::getAccountIDPeer
AccountID const & getAccountIDPeer() const
Definition: RippleState.h:72
ripple::RippleState::~RippleState
virtual ~RippleState()=default
ripple::RippleState::sle_
std::shared_ptr< SLE const > sle_
Definition: RippleState.h:150
ripple::RippleState::makeItem
static RippleState::pointer makeItem(AccountID const &accountID, std::shared_ptr< SLE const > sle)
Definition: RippleState.cpp:29
ripple::RippleState::getQualityOut
Rate const & getQualityOut() const
Definition: RippleState.h:141
ripple::RippleState::getNoRipple
bool getNoRipple() const
Definition: RippleState.h:91
ripple::RippleState::getFreeze
bool getFreeze() const
Have we set the freeze flag on our peer.
Definition: RippleState.h:104
ripple::STAmount
Definition: STAmount.h:42
ripple::RippleState::getNoRipplePeer
bool getNoRipplePeer() const
Definition: RippleState.h:97
ripple::RippleState::mHighLimit
STAmount const & mHighLimit
Definition: RippleState.h:157
ripple::RippleState::getJson
Json::Value getJson(int)
Definition: RippleState.cpp:61
cstdint
std::uint32_t
ripple::RippleState::key
uint256 key() const
Returns the state map key for the ledger entry.
Definition: RippleState.h:58
memory
ripple::lsfHighNoRipple
@ lsfHighNoRipple
Definition: LedgerFormats.h:126
ripple::lsfHighFreeze
@ lsfHighFreeze
Definition: LedgerFormats.h:128
ripple::RippleState::mLowLimit
STAmount const & mLowLimit
Definition: RippleState.h:156
ripple::RippleState::lowQualityIn_
Rate lowQualityIn_
Definition: RippleState.h:162
ripple::ReadView
A view into a ledger.
Definition: ReadView.h:188
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::RippleState::getBalance
STAmount const & getBalance() const
Definition: RippleState.h:117
ripple::RippleState::RippleState
RippleState()=delete
ripple::RippleState::mBalance
STAmount mBalance
Definition: RippleState.h:167
ripple::lsfLowFreeze
@ lsfLowFreeze
Definition: LedgerFormats.h:127
ripple::RippleState::mViewLowest
bool mViewLowest
Definition: RippleState.h:152
ripple::RippleState::mHighID
AccountID const & mHighID
Definition: RippleState.h:160
ripple::RippleState::getLimitPeer
STAmount const & getLimitPeer() const
Definition: RippleState.h:129
ripple::RippleState::mFlags
std::uint32_t mFlags
Definition: RippleState.h:154
Json::Value
Represents a JSON value.
Definition: json_value.h:145