diff --git a/libraries/app/api_objects.cpp b/libraries/app/api_objects.cpp index e002f061ae..80f7c4b052 100644 --- a/libraries/app/api_objects.cpp +++ b/libraries/app/api_objects.cpp @@ -31,7 +31,7 @@ market_ticker::market_ticker(const market_ticker_object& mto, const fc::time_point_sec& now, const asset_object& asset_base, const asset_object& asset_quote, - const order_book& orders) + const optional& orders) { time = now; base = asset_base.symbol; @@ -67,10 +67,13 @@ market_ticker::market_ticker(const market_ticker_object& mto, base_volume = uint128_amount_to_string( bv, asset_base.precision ); quote_volume = uint128_amount_to_string( qv, asset_quote.precision ); - if(!orders.asks.empty()) - lowest_ask = orders.asks[0].price; - if(!orders.bids.empty()) - highest_bid = orders.bids[0].price; + if( orders.valid() ) + { + if( !orders->asks.empty() ) + lowest_ask = orders->asks[0].price; + if( !orders->bids.empty() ) + highest_bid = orders->bids[0].price; + } } market_ticker::market_ticker(const fc::time_point_sec& now, diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index d19a8daae2..d6c54904a0 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -937,7 +937,9 @@ vector> database_api_impl::lookup_asset_symbols( result.reserve(symbols_or_ids.size()); std::transform(symbols_or_ids.begin(), symbols_or_ids.end(), std::back_inserter(result), [this, &assets_by_symbol](const string& symbol_or_id) -> optional { - if( !symbol_or_id.empty() && std::isdigit(symbol_or_id[0]) ) + if( symbol_or_id.empty() ) + return optional(); + if( std::isdigit(symbol_or_id[0]) ) { auto ptr = _db.find(variant(symbol_or_id, 1).as(1)); return ptr == nullptr? optional() : extend_asset( *ptr ); @@ -991,12 +993,14 @@ vector database_api_impl::get_account_limit_orders( if (account == nullptr) return results; - auto assets = lookup_asset_symbols( {base, quote} ); - FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); - FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); + const asset_object* base_ptr = get_asset_from_string( base, false ); + FC_ASSERT( base_ptr, "Invalid base asset: ${s}", ("s",base) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + const asset_object* quote_ptr = get_asset_from_string( quote, false ); + FC_ASSERT( quote_ptr, "Invalid quote asset: ${s}", ("s",quote) ); + + asset_id_type base_id = base_ptr->id; + asset_id_type quote_id = quote_ptr->id; if (ostart_price.valid()) { FC_ASSERT(ostart_price->base.asset_id == base_id, "Base asset inconsistent with start price"); @@ -1262,28 +1266,29 @@ market_ticker database_api_impl::get_ticker( const string& base, const string& q { FC_ASSERT( _app_options && _app_options->has_market_history_plugin, "Market history plugin is not enabled." ); - const auto assets = lookup_asset_symbols( {base, quote} ); + const asset_object* base_ptr = get_asset_from_string( base, false ); + FC_ASSERT( base_ptr, "Invalid base asset: ${s}", ("s",base) ); - FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); - FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); + const asset_object* quote_ptr = get_asset_from_string( quote, false ); + FC_ASSERT( quote_ptr, "Invalid quote asset: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + asset_id_type base_id = base_ptr->id; + asset_id_type quote_id = quote_ptr->id; if( base_id > quote_id ) std::swap( base_id, quote_id ); const auto& ticker_idx = _db.get_index_type().indices().get(); auto itr = ticker_idx.find( std::make_tuple( base_id, quote_id ) ); const fc::time_point_sec now = _db.head_block_time(); if( itr != ticker_idx.end() ) { - order_book orders; + optional orders; if (!skip_order_book) { - orders = get_order_book(assets[0]->symbol, assets[1]->symbol, 1); + orders = get_order_book( *base_ptr, *quote_ptr, 1 ); } - return market_ticker(*itr, now, *assets[0], *assets[1], orders); + return market_ticker(*itr, now, *base_ptr, *quote_ptr, orders); } // if no ticker is found for this market we return an empty ticker - market_ticker empty_result(now, *assets[0], *assets[1]); + market_ticker empty_result(now, *base_ptr, *quote_ptr); return empty_result; } @@ -1316,72 +1321,73 @@ order_book database_api_impl::get_order_book( const string& base, const string& uint64_t api_limit_get_order_book=_app_options->api_limit_get_order_book; FC_ASSERT( limit <= api_limit_get_order_book ); - order_book result; - result.base = base; - result.quote = quote; + const asset_object* base_ptr = get_asset_from_string( base, false ); + FC_ASSERT( base_ptr, "Invalid base asset: ${s}", ("s",base) ); - auto assets = lookup_asset_symbols( {base, quote} ); - FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); - FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); + const asset_object* quote_ptr = get_asset_from_string( quote, false ); + FC_ASSERT( quote_ptr, "Invalid quote asset: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; - auto orders = get_limit_orders( base_id, quote_id, limit ); - - for( const auto& o : orders ) - { - if( o.sell_price.base.asset_id == base_id ) - { - order ord; - ord.price = price_to_string( o.sell_price, *assets[0], *assets[1] ); - ord.quote = assets[1]->amount_to_string( share_type( fc::uint128_t( o.for_sale.value ) - * o.sell_price.quote.amount.value - / o.sell_price.base.amount.value ) ); - ord.base = assets[0]->amount_to_string( o.for_sale ); - result.bids.push_back( ord ); - } - else - { - order ord; - ord.price = price_to_string( o.sell_price, *assets[0], *assets[1] ); - ord.quote = assets[1]->amount_to_string( o.for_sale ); - ord.base = assets[0]->amount_to_string( share_type( fc::uint128_t( o.for_sale.value ) - * o.sell_price.quote.amount.value - / o.sell_price.base.amount.value ) ); - result.asks.push_back( ord ); - } - } + order_book result = get_order_book( *base_ptr, *quote_ptr, limit ); + result.base = base; + result.quote = quote; return result; } -vector database_api::get_top_markets(uint32_t limit)const +vector database_api::get_top_markets( uint32_t limit, const optional& base )const { - return my->get_top_markets(limit); + return my->get_top_markets( limit, base ); } -vector database_api_impl::get_top_markets(uint32_t limit)const +vector database_api_impl::get_top_markets( uint32_t limit, const optional& base )const { FC_ASSERT( _app_options && _app_options->has_market_history_plugin, "Market history plugin is not enabled." ); FC_ASSERT( limit <= 100 ); - const auto& volume_idx = _db.get_index_type().indices().get(); - auto itr = volume_idx.rbegin(); vector result; + + if( limit == 0 ) // shortcut to save a DB query + return result; + result.reserve(limit); const fc::time_point_sec now = _db.head_block_time(); - while( itr != volume_idx.rend() && result.size() < limit) + if( !base.valid() || *base == "" ) + { + std::set> inserted; + const auto& volume_idx = _db.get_index_type().indices().get(); + for( auto itr = volume_idx.begin(); limit > 0 && itr != volume_idx.end(); ++itr ) + { + const auto& tick = *itr; + // skip if the flipped market is already in the result + if( inserted.find( std::make_pair( tick.quote, tick.base ) ) != inserted.end() ) + continue; + inserted.insert( std::make_pair( tick.base, tick.quote ) ); + + const asset_object& base_obj = tick.base(_db); + const asset_object& quote_obj = tick.quote(_db); + order_book orders = get_order_book( base_obj, quote_obj, 1 ); + result.emplace_back( tick, now, base_obj, quote_obj, orders ); + --limit; + } + } + else // specified base asset { - const asset_object base = itr->base(_db); - const asset_object quote = itr->quote(_db); - order_book orders; - orders = get_order_book(base.symbol, quote.symbol, 1); + const asset_object& base_obj = *get_asset_from_string( *base ); - result.emplace_back(market_ticker(*itr, now, base, quote, orders)); - ++itr; + const auto& asset_volume_idx = _db.get_index_type().indices().get(); + auto range = asset_volume_idx.equal_range( base_obj.id ); + + for( auto itr = range.first; limit > 0 && itr != range.second; ++itr, --limit ) + { + const auto& tick = *itr; + const asset_object& quote_obj = tick.quote(_db); + order_book orders = get_order_book( base_obj, quote_obj, 1 ); + result.emplace_back( tick, now, base_obj, quote_obj, orders ); + } } + return result; } @@ -1404,12 +1410,14 @@ vector database_api_impl::get_trade_history( const string& base, FC_ASSERT( limit <= 100 ); - auto assets = lookup_asset_symbols( {base, quote} ); - FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); - FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); + const asset_object* base_ptr = get_asset_from_string( base, false ); + FC_ASSERT( base_ptr, "Invalid base asset: ${s}", ("s",base) ); + + const asset_object* quote_ptr = get_asset_from_string( quote, false ); + FC_ASSERT( quote_ptr, "Invalid quote asset: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + asset_id_type base_id = base_ptr->id; + asset_id_type quote_id = quote_ptr->id; if( base_id > quote_id ) std::swap( base_id, quote_id ); @@ -1427,19 +1435,19 @@ vector database_api_impl::get_trade_history( const string& base, { market_trade trade; - if( assets[0]->id == itr->op.receives.asset_id ) + if( base_id == itr->op.receives.asset_id ) { - trade.amount = assets[1]->amount_to_string( itr->op.pays ); - trade.value = assets[0]->amount_to_string( itr->op.receives ); + trade.amount = quote_ptr->amount_to_string( itr->op.pays ); + trade.value = base_ptr->amount_to_string( itr->op.receives ); } else { - trade.amount = assets[1]->amount_to_string( itr->op.receives ); - trade.value = assets[0]->amount_to_string( itr->op.pays ); + trade.amount = quote_ptr->amount_to_string( itr->op.receives ); + trade.value = base_ptr->amount_to_string( itr->op.pays ); } trade.date = itr->time; - trade.price = price_to_string( itr->op.fill_price, *assets[0], *assets[1] ); + trade.price = price_to_string( itr->op.fill_price, *base_ptr, *quote_ptr ); if( itr->op.is_maker ) { @@ -1498,12 +1506,14 @@ vector database_api_impl::get_trade_history_by_sequence( FC_ASSERT( start >= 0 ); int64_t start_seq = -start; - auto assets = lookup_asset_symbols( {base, quote} ); - FC_ASSERT( assets[0], "Invalid base asset symbol: ${s}", ("s",base) ); - FC_ASSERT( assets[1], "Invalid quote asset symbol: ${s}", ("s",quote) ); + const asset_object* base_ptr = get_asset_from_string( base, false ); + FC_ASSERT( base_ptr, "Invalid base asset: ${s}", ("s",base) ); + + const asset_object* quote_ptr = get_asset_from_string( quote, false ); + FC_ASSERT( quote_ptr, "Invalid quote asset: ${s}", ("s",quote) ); - auto base_id = assets[0]->id; - auto quote_id = assets[1]->id; + asset_id_type base_id = base_ptr->id; + asset_id_type quote_id = quote_ptr->id; if( base_id > quote_id ) std::swap( base_id, quote_id ); const auto& history_idx = _db.get_index_type().indices().get(); @@ -1533,19 +1543,19 @@ vector database_api_impl::get_trade_history_by_sequence( { market_trade trade; - if( assets[0]->id == itr->op.receives.asset_id ) + if( base_id == itr->op.receives.asset_id ) { - trade.amount = assets[1]->amount_to_string( itr->op.pays ); - trade.value = assets[0]->amount_to_string( itr->op.receives ); + trade.amount = quote_ptr->amount_to_string( itr->op.pays ); + trade.value = base_ptr->amount_to_string( itr->op.receives ); } else { - trade.amount = assets[1]->amount_to_string( itr->op.receives ); - trade.value = assets[0]->amount_to_string( itr->op.pays ); + trade.amount = quote_ptr->amount_to_string( itr->op.receives ); + trade.value = base_ptr->amount_to_string( itr->op.pays ); } trade.date = itr->time; - trade.price = price_to_string( itr->op.fill_price, *assets[0], *assets[1] ); + trade.price = price_to_string( itr->op.fill_price, *base_ptr, *quote_ptr ); if( itr->op.is_maker ) { @@ -2409,9 +2419,6 @@ vector> database_api_impl::get_assets( const vec vector database_api_impl::get_limit_orders( const asset_id_type a, const asset_id_type b, const uint32_t limit )const { - uint64_t api_limit_get_limit_orders=_app_options->api_limit_get_limit_orders; - FC_ASSERT( limit <= api_limit_get_limit_orders ); - const auto& limit_order_idx = _db.get_index_type(); const auto& limit_price_idx = limit_order_idx.indices().get(); @@ -2440,6 +2447,58 @@ vector database_api_impl::get_limit_orders( const asset_id_t return result; } +// helper function for fewer DB queries +order_book database_api_impl::get_order_book( const asset_object& base, const asset_object& quote, + unsigned limit )const +{ + order_book result; + + asset_id_type base_id = base.id; + asset_id_type quote_id = quote.id; + + const auto& limit_price_idx = _db.get_index_type().indices().get(); + + uint32_t count = 0; + auto limit_itr = limit_price_idx.lower_bound( price::max( base_id, quote_id ) ); + auto limit_end = limit_price_idx.upper_bound( price::min( base_id, quote_id ) ); + while( limit_itr != limit_end && count < limit ) + { + const auto& o = *limit_itr; + + order ord; + ord.price = price_to_string( o.sell_price, base, quote ); + ord.quote = quote.amount_to_string( share_type( fc::uint128_t( o.for_sale.value ) + * o.sell_price.quote.amount.value + / o.sell_price.base.amount.value ) ); + ord.base = base.amount_to_string( o.for_sale ); + result.bids.push_back( std::move(ord) ); + + ++limit_itr; + ++count; + } + + count = 0; + limit_itr = limit_price_idx.lower_bound( price::max( quote_id, base_id ) ); + limit_end = limit_price_idx.upper_bound( price::min( quote_id, base_id ) ); + while( limit_itr != limit_end && count < limit ) + { + const auto& o = *limit_itr; + + order ord; + ord.price = price_to_string( o.sell_price, base, quote ); + ord.quote = quote.amount_to_string( o.for_sale ); + ord.base = base.amount_to_string( share_type( fc::uint128_t( o.for_sale.value ) + * o.sell_price.quote.amount.value + / o.sell_price.base.amount.value ) ); + result.asks.push_back( std::move(ord) ); + + ++limit_itr; + ++count; + } + + return result; +} + bool database_api_impl::is_impacted_account( const flat_set& accounts) { if( !_subscribed_accounts.size() || !accounts.size() ) diff --git a/libraries/app/database_api_impl.hxx b/libraries/app/database_api_impl.hxx index e2e7c376a4..577dd0b1b2 100644 --- a/libraries/app/database_api_impl.hxx +++ b/libraries/app/database_api_impl.hxx @@ -126,7 +126,7 @@ class database_api_impl : public std::enable_shared_from_this market_volume get_24_volume( const string& base, const string& quote )const; order_book get_order_book( const string& base, const string& quote, unsigned limit = 50 )const; - vector get_top_markets( uint32_t limit )const; + vector get_top_markets( uint32_t limit, const optional& base )const; vector get_trade_history( const string& base, const string& quote, fc::time_point_sec start, fc::time_point_sec stop, unsigned limit = 100 )const; @@ -235,6 +235,10 @@ class database_api_impl : public std::enable_shared_from_this vector get_limit_orders( const asset_id_type a, const asset_id_type b, const uint32_t limit )const; + // helper function for fewer DB queries + order_book get_order_book( const asset_object& base, const asset_object& quote, + unsigned limit = 50 )const; + //////////////////////////////////////////////// // Subscription //////////////////////////////////////////////// diff --git a/libraries/app/include/graphene/app/api_objects.hpp b/libraries/app/include/graphene/app/api_objects.hpp index af7a96e1ab..d4e53eec9a 100644 --- a/libraries/app/include/graphene/app/api_objects.hpp +++ b/libraries/app/include/graphene/app/api_objects.hpp @@ -110,7 +110,7 @@ namespace graphene { namespace app { const fc::time_point_sec& now, const asset_object& asset_base, const asset_object& asset_quote, - const order_book& orders); + const optional& orders); market_ticker(const fc::time_point_sec& now, const asset_object& asset_base, const asset_object& asset_quote); diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 1960e64824..0814f43d61 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -564,9 +564,12 @@ class database_api * @brief Returns vector of tickers sorted by reverse base_volume * Note: this API is experimental and subject to change in next releases * @param limit Max number of results + * @param base symbol name or ID of the base asset, optional, + * if specified and is not empty, will only return tickers of the specified base asset, + * otherwise will return tickers of all assets * @return Desc Sorted ticker vector */ - vector get_top_markets(uint32_t limit)const; + vector get_top_markets( uint32_t limit, const optional& base = {} )const; /** * @brief Returns recent trades for the market base:quote, ordered by time, most recent first. diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index 46a8feb54e..84ce276d39 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -30,7 +30,7 @@ #define GRAPHENE_MAX_NESTED_OBJECTS (200) -#define GRAPHENE_CURRENT_DB_VERSION "20190503" +#define GRAPHENE_CURRENT_DB_VERSION "20190814" #define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4 #define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3 diff --git a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp index 51eca0d857..28bdbf333c 100644 --- a/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp +++ b/libraries/plugins/market_history/include/graphene/market_history/market_history_plugin.hpp @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -53,7 +52,8 @@ enum market_history_object_type order_history_object_type = 0, bucket_object_type = 1, market_ticker_object_type = 2, - market_ticker_meta_object_type = 3 + market_ticker_meta_object_type = 3, + asset_trading_stats_object_type = 4 }; struct bucket_key @@ -195,18 +195,30 @@ typedef multi_index_container< struct by_market; struct by_volume; +struct by_asset_volume; typedef multi_index_container< market_ticker_object, indexed_by< ordered_unique< tag, member< object, object_id_type, &object::id > >, - ordered_non_unique< tag, - member< market_ticker_object, fc::uint128_t, &market_ticker_object::base_volume > >, - ordered_unique< - tag, - composite_key< - market_ticker_object, - member, - member + ordered_unique< tag, + composite_key< market_ticker_object, + member< market_ticker_object, fc::uint128_t, &market_ticker_object::base_volume >, + member< object, object_id_type, &object::id > + >, + composite_key_compare< std::greater, std::less > + >, + ordered_unique< tag, + composite_key< market_ticker_object, + member< market_ticker_object, asset_id_type, &market_ticker_object::base >, + member< market_ticker_object, fc::uint128_t, &market_ticker_object::base_volume >, + member< object, object_id_type, &object::id > + >, + composite_key_compare< std::less, std::greater, std::less > + >, + ordered_unique< tag, + composite_key< market_ticker_object, + member< market_ticker_object, asset_id_type, &market_ticker_object::base >, + member< market_ticker_object, asset_id_type, &market_ticker_object::quote > > > > diff --git a/libraries/plugins/market_history/market_history_plugin.cpp b/libraries/plugins/market_history/market_history_plugin.cpp index 6b4a3558c4..23b847596f 100644 --- a/libraries/plugins/market_history/market_history_plugin.cpp +++ b/libraries/plugins/market_history/market_history_plugin.cpp @@ -181,7 +181,7 @@ struct operation_process_fill_order auto ticker_itr = ticker_idx.find( std::make_tuple( key.base, key.quote ) ); if( ticker_itr == ticker_idx.end() ) { - db.create( [&]( market_ticker_object& mt ) { + db.create( [&key,&fill_price,&trade_price]( market_ticker_object& mt ) { mt.base = key.base; mt.quote = key.quote; mt.last_day_base = 0; @@ -191,15 +191,37 @@ struct operation_process_fill_order mt.base_volume = trade_price.base.amount.value; mt.quote_volume = trade_price.quote.amount.value; }); + // save an object for "flipped" market for get_top_markets API + db.create( [&key,&fill_price,&trade_price]( market_ticker_object& mt ) { + mt.base = key.quote; + mt.quote = key.base; + mt.last_day_base = 0; + mt.last_day_quote = 0; + mt.latest_base = fill_price.quote.amount; + mt.latest_quote = fill_price.base.amount; + mt.base_volume = trade_price.quote.amount.value; + mt.quote_volume = trade_price.base.amount.value; + }); } else { - db.modify( *ticker_itr, [&]( market_ticker_object& mt ) { + db.modify( *ticker_itr, [&fill_price,&trade_price]( market_ticker_object& mt ) { mt.latest_base = fill_price.base.amount; mt.latest_quote = fill_price.quote.amount; mt.base_volume += trade_price.base.amount.value; // ignore overflow mt.quote_volume += trade_price.quote.amount.value; // ignore overflow }); + // update data of flipped market + auto flipped_ticker_itr = ticker_idx.find( std::make_tuple( key.quote, key.base ) ); + if( flipped_ticker_itr != ticker_idx.end() ) // should always be true + { + db.modify( *flipped_ticker_itr, [&fill_price,&trade_price]( market_ticker_object& mt ) { + mt.latest_base = fill_price.quote.amount; + mt.latest_quote = fill_price.base.amount; + mt.base_volume += trade_price.quote.amount.value; // ignore overflow + mt.quote_volume += trade_price.base.amount.value; // ignore overflow + }); + } } // To update buckets data @@ -347,13 +369,24 @@ void market_history_plugin_impl::update_market_histories( const signed_block& b auto ticker_itr = ticker_idx.find( std::make_tuple( key.base, key.quote ) ); if( ticker_itr != ticker_idx.end() ) // should always be true { - db.modify( *ticker_itr, [&]( market_ticker_object& mt ) { + db.modify( *ticker_itr, [&fill_price,&trade_price]( market_ticker_object& mt ) { mt.last_day_base = fill_price.base.amount; mt.last_day_quote = fill_price.quote.amount; mt.base_volume -= trade_price.base.amount.value; // ignore underflow mt.quote_volume -= trade_price.quote.amount.value; // ignore underflow }); } + // update data of flipped market + ticker_itr = ticker_idx.find( std::make_tuple( key.quote, key.base ) ); + if( ticker_itr != ticker_idx.end() ) // should always be true + { + db.modify( *ticker_itr, [&fill_price,&trade_price]( market_ticker_object& mt ) { + mt.last_day_base = fill_price.quote.amount; + mt.last_day_quote = fill_price.base.amount; + mt.base_volume -= trade_price.quote.amount.value; // ignore underflow + mt.quote_volume -= trade_price.base.amount.value; // ignore underflow + }); + } } last_min_his_id = history_itr->id; ++history_itr; diff --git a/tests/tests/settle_tests.cpp b/tests/tests/settle_tests.cpp index 6310493ae5..38f52f4217 100644 --- a/tests/tests/settle_tests.cpp +++ b/tests/tests/settle_tests.cpp @@ -1538,7 +1538,7 @@ BOOST_AUTO_TEST_CASE( global_settle_ticker_test ) { BOOST_CHECK_EQUAL( meta_idx.size(), 1 ); - BOOST_CHECK_EQUAL( ticker_idx.size(), 1 ); + BOOST_CHECK_EQUAL( ticker_idx.size(), 2 ); BOOST_CHECK_EQUAL( history_idx.size(), 1 ); const auto& meta = *meta_idx.begin(); @@ -1558,7 +1558,7 @@ BOOST_AUTO_TEST_CASE( global_settle_ticker_test ) // nothing changes { BOOST_CHECK_EQUAL( meta_idx.size(), 1 ); - BOOST_CHECK_EQUAL( ticker_idx.size(), 1 ); + BOOST_CHECK_EQUAL( ticker_idx.size(), 2 ); BOOST_CHECK_EQUAL( history_idx.size(), 1 ); const auto& meta = *meta_idx.begin(); @@ -1578,7 +1578,7 @@ BOOST_AUTO_TEST_CASE( global_settle_ticker_test ) // the history is rolled out, new 24h volume should be 0 { BOOST_CHECK_EQUAL( meta_idx.size(), 1 ); - BOOST_CHECK_EQUAL( ticker_idx.size(), 1 ); + BOOST_CHECK_EQUAL( ticker_idx.size(), 2 ); BOOST_CHECK_EQUAL( history_idx.size(), 1 ); const auto& meta = *meta_idx.begin(); @@ -1598,7 +1598,7 @@ BOOST_AUTO_TEST_CASE( global_settle_ticker_test ) // nothing changes { BOOST_CHECK_EQUAL( meta_idx.size(), 1 ); - BOOST_CHECK_EQUAL( ticker_idx.size(), 1 ); + BOOST_CHECK_EQUAL( ticker_idx.size(), 2 ); BOOST_CHECK_EQUAL( history_idx.size(), 1 ); const auto& meta = *meta_idx.begin();