diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 23d02087..0bcace13 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -950,7 +950,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 3e3b60b5..f8cef076 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -187,12 +187,13 @@ void database::close(bool rewind) 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 c1bfd3f5..6a157e31 100644 --- a/libraries/chain/include/graphene/chain/asset_object.hpp +++ b/libraries/chain/include/graphene/chain/asset_object.hpp @@ -259,6 +259,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(); } }; @@ -267,6 +268,7 @@ namespace graphene { namespace chain { struct by_type; struct active_lotteries; struct by_lottery; + struct by_lottery_owner; typedef multi_index_container< asset_object, indexed_by< @@ -277,6 +279,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, @@ -299,6 +312,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 *