rippled
Loading...
Searching...
No Matches
AccountCurrencies.cpp
1#include <xrpld/app/paths/AccountCurrencies.h>
2
3namespace ripple {
4
5hash_set<Currency>
7 AccountID const& account,
9 bool includeXRP)
10{
11 hash_set<Currency> currencies;
12
13 // YYY Only bother if they are above reserve
14 if (includeXRP)
15 currencies.insert(xrpCurrency());
16
17 if (auto const lines =
18 lrCache->getRippleLines(account, LineDirection::outgoing))
19 {
20 for (auto const& rspEntry : *lines)
21 {
22 auto& saBalance = rspEntry.getBalance();
23
24 // Filter out non
25 if (saBalance > beast::zero
26 // Have IOUs to send.
27 ||
28 (rspEntry.getLimitPeer()
29 // Peer extends credit.
30 && ((-saBalance) < rspEntry.getLimitPeer()))) // Credit left.
31 {
32 currencies.insert(saBalance.getCurrency());
33 }
34 }
35 }
36
37 currencies.erase(badCurrency());
38 return currencies;
39}
40
41hash_set<Currency>
43 AccountID const& account,
45 bool includeXRP)
46{
47 hash_set<Currency> currencies;
48
49 if (includeXRP)
50 currencies.insert(xrpCurrency());
51 // Even if account doesn't exist
52
53 if (auto const lines =
54 lrCache->getRippleLines(account, LineDirection::outgoing))
55 {
56 for (auto const& rspEntry : *lines)
57 {
58 auto& saBalance = rspEntry.getBalance();
59
60 if (saBalance < rspEntry.getLimit()) // Can take more
61 currencies.insert(saBalance.getCurrency());
62 }
63 }
64
65 currencies.erase(badCurrency());
66 return currencies;
67}
68
69} // namespace ripple
T erase(T... args)
T insert(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
hash_set< Currency > accountDestCurrencies(AccountID const &account, std::shared_ptr< RippleLineCache > const &lrCache, bool includeXRP)
hash_set< Currency > accountSourceCurrencies(AccountID const &account, std::shared_ptr< RippleLineCache > const &lrCache, bool includeXRP)
Currency const & xrpCurrency()
XRP currency.