rippled
Loading...
Searching...
No Matches
detail/AccountCurrencies.cpp
1#include <xrpld/rpc/detail/AccountCurrencies.h>
2
3namespace xrpl {
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 = lrCache->getRippleLines(account, LineDirection::outgoing))
18 {
19 for (auto const& rspEntry : *lines)
20 {
21 auto& saBalance = rspEntry.getBalance();
22
23 // Filter out non
24 if (saBalance > beast::zero
25 // Have IOUs to send.
26 || (rspEntry.getLimitPeer()
27 // Peer extends credit.
28 && ((-saBalance) < rspEntry.getLimitPeer()))) // Credit left.
29 {
30 currencies.insert(saBalance.getCurrency());
31 }
32 }
33 }
34
35 currencies.erase(badCurrency());
36 return currencies;
37}
38
39hash_set<Currency>
41 AccountID const& account,
43 bool includeXRP)
44{
45 hash_set<Currency> currencies;
46
47 if (includeXRP)
48 currencies.insert(xrpCurrency());
49 // Even if account doesn't exist
50
51 if (auto const lines = lrCache->getRippleLines(account, LineDirection::outgoing))
52 {
53 for (auto const& rspEntry : *lines)
54 {
55 auto& saBalance = rspEntry.getBalance();
56
57 if (saBalance < rspEntry.getLimit()) // Can take more
58 currencies.insert(saBalance.getCurrency());
59 }
60 }
61
62 currencies.erase(badCurrency());
63 return currencies;
64}
65
66} // namespace xrpl
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:5
hash_set< Currency > accountSourceCurrencies(AccountID const &account, std::shared_ptr< RippleLineCache > const &lrCache, bool includeXRP)
Currency const & xrpCurrency()
XRP currency.
Definition UintTypes.cpp:98
hash_set< Currency > accountDestCurrencies(AccountID const &account, std::shared_ptr< RippleLineCache > const &lrCache, bool includeXRP)
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...