Пример #1
0
void OrderBookDB::update (Ledger::pointer ledger)
{
    boost::unordered_set< uint256 > seen;
    boost::unordered_map< currencyIssuer_t, std::vector<OrderBook::pointer> > destMap;
    boost::unordered_map< currencyIssuer_t, std::vector<OrderBook::pointer> > sourceMap;
    boost::unordered_set< currencyIssuer_t > XRPBooks;

    WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update>";

    // walk through the entire ledger looking for orderbook entries
    int books = 0;

    try
    {
        ledger->visitStateItems(BIND_TYPE(&updateHelper, P_1, boost::ref(seen), boost::ref(destMap),
            boost::ref(sourceMap), boost::ref(XRPBooks), boost::ref(books)));
    }
    catch (const SHAMapMissingNode&)
    {
        WriteLog (lsINFO, OrderBookDB) << "OrderBookDB::update encountered a missing node";
        ScopedLockType sl (mLock, __FILE__, __LINE__);
        mSeq = 0;
        return;
    }

    WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update< " << books << " books found";
    {
        ScopedLockType sl (mLock, __FILE__, __LINE__);

        mXRPBooks.swap(XRPBooks);
        mSourceMap.swap(sourceMap);
        mDestMap.swap(destMap);
    }
    getApp().getLedgerMaster().newOrderBookDB();
}
Пример #2
0
void OrderBookDB::update (Ledger::pointer ledger)
{
    hash_set< uint256 > seen;
    OrderBookDB::IssueToOrderBook destMap;
    OrderBookDB::IssueToOrderBook sourceMap;
    hash_set< Issue > XDVBooks;

    WriteLog (lsDEBUG, OrderBookDB) << "OrderBookDB::update>";

    // walk through the entire ledger looking for orderbook entries
    int books = 0;

    try
    {
        ledger->visitStateItems(std::bind(&updateHelper, std::placeholders::_1,
                                          std::ref(seen), std::ref(destMap),
            std::ref(sourceMap), std::ref(XDVBooks), std::ref(books)));
    }
    catch (const SHAMapMissingNode&)
    {
        WriteLog (lsINFO, OrderBookDB)
            << "OrderBookDB::update encountered a missing node";
        ScopedLockType sl (mLock);
        mSeq = 0;
        return;
    }

    WriteLog (lsDEBUG, OrderBookDB)
        << "OrderBookDB::update< " << books << " books found";
    {
        ScopedLockType sl (mLock);

        mXDVBooks.swap(XDVBooks);
        mSourceMap.swap(sourceMap);
        mDestMap.swap(destMap);
    }
    getApp().getLedgerMaster().newOrderBookDB();
}