fixed indices sorting and lottery end checking by date
This commit is contained in:
parent
1baa751ba3
commit
dd26890a1d
3 changed files with 18 additions and 3 deletions
|
|
@ -1070,7 +1070,7 @@ vector<asset_object> database_api_impl::get_account_lotteries( account_id_type i
|
|||
{
|
||||
vector<asset_object> result;
|
||||
if( limit > 100 ) limit = 100;
|
||||
const auto& assets = _db.get_index_type<asset_index>().indices().get<by_lottery>();
|
||||
const auto& assets = _db.get_index_type<asset_index>().indices().get<by_lottery_owner>();
|
||||
|
||||
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 ) )
|
||||
|
|
|
|||
|
|
@ -209,12 +209,13 @@ void database::force_slow_replays()
|
|||
void database::check_ending_lotteries()
|
||||
{
|
||||
try {
|
||||
const auto& lotteries_idx = get_index_type<asset_index>().indices().get<active_lotteries>();
|
||||
const auto& lotteries_idx = get_index_type<asset_index>().indices().get<active_lotteries>();
|
||||
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( ... ) {}
|
||||
|
|
|
|||
|
|
@ -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<by_lottery>,
|
||||
composite_key<
|
||||
asset_object,
|
||||
const_mem_fun<asset_object, bool, &asset_object::is_lottery>,
|
||||
member<object, object_id_type, &object::id>
|
||||
>,
|
||||
composite_key_compare<
|
||||
std::greater< bool >,
|
||||
std::greater< object_id_type >
|
||||
>
|
||||
>,
|
||||
ordered_unique< tag<by_lottery_owner>,
|
||||
composite_key<
|
||||
asset_object,
|
||||
const_mem_fun<asset_object, bool, &asset_object::is_lottery>,
|
||||
|
|
@ -302,6 +315,7 @@ namespace graphene { namespace chain {
|
|||
> asset_object_multi_index_type;
|
||||
typedef generic_index<asset_object, asset_object_multi_index_type> asset_index;
|
||||
|
||||
|
||||
/**
|
||||
* @brief contains properties that only apply to dividend-paying assets
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue