diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index d2bfacc2..3a863d34 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -1070,7 +1070,7 @@ vector database_api_impl::get_account_lotteries( account_id_type i { vector result; if( limit > 100 ) limit = 100; - const auto& assets = _db.get_index_type().indices().get(); + const auto& assets = _db.get_index_type().indices().get(); const auto range = assets.equal_range( boost::make_tuple( true, issuer.instance.value ) ); for( const auto& a : boost::make_iterator_range( range.first, range.second ) ) diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index e0681455..68f6fad1 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -209,12 +209,13 @@ void database::force_slow_replays() void database::check_ending_lotteries() { try { - const auto& lotteries_idx = get_index_type().indices().get(); + const auto& lotteries_idx = get_index_type().indices().get(); for( auto checking_asset: lotteries_idx ) { FC_ASSERT( checking_asset.is_lottery() ); FC_ASSERT( checking_asset.lottery_options->is_active ); - FC_ASSERT( checking_asset.lottery_options->end_date < head_block_time() ); + FC_ASSERT( checking_asset.lottery_options->end_date != time_point_sec() ); + if( checking_asset.lottery_options->end_date > head_block_time() ) continue; checking_asset.end_lottery(*this); } } catch( ... ) {} diff --git a/libraries/chain/include/graphene/chain/asset_object.hpp b/libraries/chain/include/graphene/chain/asset_object.hpp index d12335d6..706cadcb 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -260,6 +260,7 @@ namespace graphene { namespace chain { if ( !lhs.is_lottery() ) return false; if ( !lhs.lottery_options->is_active && !rhs.is_lottery()) return true; // not active lotteries first, just assets then if ( !lhs.lottery_options->is_active ) return false; + if ( lhs.lottery_options->is_active && ( !rhs.is_lottery() || !rhs.lottery_options->is_active ) ) return true; return lhs.get_lottery_expiration() > rhs.get_lottery_expiration(); } }; @@ -269,6 +270,7 @@ namespace graphene { namespace chain { struct by_issuer; struct active_lotteries; struct by_lottery; + struct by_lottery_owner; typedef multi_index_container< asset_object, indexed_by< @@ -280,6 +282,17 @@ namespace graphene { namespace chain { lottery_asset_comparer >, ordered_unique< tag, + composite_key< + asset_object, + const_mem_fun, + member + >, + composite_key_compare< + std::greater< bool >, + std::greater< object_id_type > + > + >, + ordered_unique< tag, composite_key< asset_object, const_mem_fun, @@ -302,6 +315,7 @@ namespace graphene { namespace chain { > asset_object_multi_index_type; typedef generic_index asset_index; + /** * @brief contains properties that only apply to dividend-paying assets *