hash_set<Currency> accountDestCurrencies (
    AccountID const& account,
    RippleLineCache::ref lrCache,
    bool includeXRP)
{
    hash_set<Currency> currencies;

    if (includeXRP) {
        currencies.insert (xrpCurrency());
        currencies.insert (vbcCurrency());
    }
    // Even if account doesn't exist

    // List of ripple lines.
    auto& rippleLines = lrCache->getRippleLines (account);

    for (auto const& item : rippleLines)
    {
        auto rspEntry = (RippleState*) item.get ();
        assert (rspEntry);
        if (!rspEntry)
            continue;

        auto& saBalance  = rspEntry->getBalance ();

        if (saBalance < rspEntry->getLimit ())                  // Can take more
            currencies.insert (saBalance.getCurrency ());
    }

    currencies.erase (badCurrency());
    return currencies;
}
Exemple #2
0
CurrencySet accountDestCurrencies (
    RippleAddress const& raAccountID,
    RippleLineCache::ref lrCache,
    bool includeXRP)
{
    CurrencySet currencies;

    if (includeXRP)
        currencies.insert (xrpCurrency());
    // Even if account doesn't exist

    // List of ripple lines.
    auto& rippleLines (lrCache->getRippleLines (raAccountID.getAccountID ()));

    for (auto const& item : rippleLines)
    {
        auto rspEntry = (RippleState*) item.get ();
        assert (rspEntry);
        if (!rspEntry)
            continue;

        auto& saBalance  = rspEntry->getBalance ();

        if (saBalance < rspEntry->getLimit ())                  // Can take more
            currencies.insert (saBalance.getCurrency ());
    }

    currencies.erase (badCurrency());
    return currencies;
}
hash_set<Currency> accountSourceCurrencies (
    AccountID const& account,
    RippleLineCache::ref lrCache,
    bool includeXRP)
{
    hash_set<Currency> currencies;

    // YYY Only bother if they are above reserve
    if (includeXRP) {
        currencies.insert (xrpCurrency());
        currencies.insert (vbcCurrency());
    }

    // List of ripple lines.
    auto& rippleLines = lrCache->getRippleLines (account);

    for (auto const& item : rippleLines)
    {
        auto rspEntry = (RippleState*) item.get ();
        assert (rspEntry);
        if (!rspEntry)
            continue;

        auto& saBalance = rspEntry->getBalance ();

        // Filter out non
        if (saBalance > zero
            // Have IOUs to send.
            || (rspEntry->getLimitPeer ()
                // Peer extends credit.
                && ((-saBalance) < rspEntry->getLimitPeer ()))) // Credit left.
        {
            currencies.insert (saBalance.getCurrency ());
        }
    }

    currencies.erase (badCurrency());
    return currencies;
}