Add api call for getting a list of upcoming tournaments
This commit is contained in:
parent
122dbfc698
commit
66bf0545c5
4 changed files with 54 additions and 0 deletions
|
|
@ -36,6 +36,7 @@
|
||||||
#include <graphene/chain/transaction_object.hpp>
|
#include <graphene/chain/transaction_object.hpp>
|
||||||
#include <graphene/chain/withdraw_permission_object.hpp>
|
#include <graphene/chain/withdraw_permission_object.hpp>
|
||||||
#include <graphene/chain/worker_object.hpp>
|
#include <graphene/chain/worker_object.hpp>
|
||||||
|
#include <graphene/chain/tournament_object.hpp>
|
||||||
|
|
||||||
#include <fc/crypto/hex.hpp>
|
#include <fc/crypto/hex.hpp>
|
||||||
#include <fc/smart_ref_impl.hpp>
|
#include <fc/smart_ref_impl.hpp>
|
||||||
|
|
@ -211,6 +212,7 @@ namespace graphene { namespace app {
|
||||||
return *_crypto_api;
|
return *_crypto_api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
vector<account_id_type> get_relevant_accounts( const object* obj )
|
vector<account_id_type> get_relevant_accounts( const object* obj )
|
||||||
{
|
{
|
||||||
vector<account_id_type> result;
|
vector<account_id_type> result;
|
||||||
|
|
@ -292,6 +294,14 @@ namespace graphene { namespace app {
|
||||||
} case balance_object_type:{
|
} case balance_object_type:{
|
||||||
/** these are free from any accounts */
|
/** these are free from any accounts */
|
||||||
break;
|
break;
|
||||||
|
} case tournament_object_type:{
|
||||||
|
const tournament_object* tournament_obj = dynamic_cast<const tournament_object*>(obj);
|
||||||
|
assert(tournament_obj);
|
||||||
|
const tournament_details_object& details = tournament_obj->tournament_details_id(*_app.chain_database());
|
||||||
|
flat_set<account_id_type> impacted = details.registered_players;
|
||||||
|
impacted.insert(tournament_obj->creator);
|
||||||
|
std::copy(impacted.begin(), impacted.end(), std::back_inserter(result));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -354,6 +364,7 @@ namespace graphene { namespace app {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} // end get_relevant_accounts( obj )
|
} // end get_relevant_accounts( obj )
|
||||||
|
#endif
|
||||||
|
|
||||||
vector<order_history_object> history_api::get_fill_order_history( asset_id_type a, asset_id_type b, uint32_t limit )const
|
vector<order_history_object> history_api::get_fill_order_history( asset_id_type a, asset_id_type b, uint32_t limit )const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <graphene/app/database_api.hpp>
|
#include <graphene/app/database_api.hpp>
|
||||||
#include <graphene/chain/get_config.hpp>
|
#include <graphene/chain/get_config.hpp>
|
||||||
|
#include <graphene/chain/tournament_object.hpp>
|
||||||
|
|
||||||
#include <fc/bloom_filter.hpp>
|
#include <fc/bloom_filter.hpp>
|
||||||
#include <fc/smart_ref_impl.hpp>
|
#include <fc/smart_ref_impl.hpp>
|
||||||
|
|
@ -137,6 +138,9 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
||||||
// Blinded balances
|
// Blinded balances
|
||||||
vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const;
|
vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const;
|
||||||
|
|
||||||
|
// Tournaments
|
||||||
|
vector<tournament_object> get_upcoming_tournaments(fc::optional<account_id_type> account_filter)const;
|
||||||
|
|
||||||
//private:
|
//private:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void subscribe_to_item( const T& i )const
|
void subscribe_to_item( const T& i )const
|
||||||
|
|
@ -1758,6 +1762,30 @@ vector<blinded_balance_object> database_api_impl::get_blinded_balances( const fl
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
// //
|
||||||
|
// Tournament methods //
|
||||||
|
// //
|
||||||
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
vector<tournament_object> database_api::get_upcoming_tournaments(fc::optional<account_id_type> account_filter)const
|
||||||
|
{
|
||||||
|
return my->get_upcoming_tournaments(account_filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<tournament_object> database_api_impl::get_upcoming_tournaments(fc::optional<account_id_type> account_filter)const
|
||||||
|
{
|
||||||
|
vector<tournament_object> result;
|
||||||
|
const auto& registration_deadline_index = _db.get_index_type<tournament_index>().indices().get<by_registration_deadline>();
|
||||||
|
const auto range = registration_deadline_index.equal_range(boost::make_tuple(tournament_state::accepting_registrations));
|
||||||
|
for (const tournament_object& tournament_obj : boost::make_iterator_range(range.first, range.second))
|
||||||
|
if (tournament_obj.options.whitelist.empty() ||
|
||||||
|
!account_filter ||
|
||||||
|
tournament_obj.options.whitelist.find(*account_filter) != tournament_obj.options.whitelist.end())
|
||||||
|
result.emplace_back(tournament_obj);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
// //
|
// //
|
||||||
// Private methods //
|
// Private methods //
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
#include <graphene/chain/proposal_object.hpp>
|
#include <graphene/chain/proposal_object.hpp>
|
||||||
#include <graphene/chain/worker_object.hpp>
|
#include <graphene/chain/worker_object.hpp>
|
||||||
#include <graphene/chain/witness_object.hpp>
|
#include <graphene/chain/witness_object.hpp>
|
||||||
|
#include <graphene/chain/tournament_object.hpp>
|
||||||
|
|
||||||
#include <graphene/market_history/market_history_plugin.hpp>
|
#include <graphene/market_history/market_history_plugin.hpp>
|
||||||
|
|
||||||
|
|
@ -548,6 +549,16 @@ class database_api
|
||||||
*/
|
*/
|
||||||
vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const;
|
vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const;
|
||||||
|
|
||||||
|
/////////////////
|
||||||
|
// Tournaments //
|
||||||
|
/////////////////
|
||||||
|
/**
|
||||||
|
* @param account_filter if provided, this will only return tournaments the given account is
|
||||||
|
* allowed to join (public tournaments or tournaments the account is whitelisted for)
|
||||||
|
* @return the list of tournaments that are still accepting new registrations
|
||||||
|
*/
|
||||||
|
vector<tournament_object> get_upcoming_tournaments(fc::optional<account_id_type> account_filter)const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr< database_api_impl > my;
|
std::shared_ptr< database_api_impl > my;
|
||||||
};
|
};
|
||||||
|
|
@ -648,4 +659,7 @@ FC_API(graphene::app::database_api,
|
||||||
|
|
||||||
// Blinded balances
|
// Blinded balances
|
||||||
(get_blinded_balances)
|
(get_blinded_balances)
|
||||||
|
|
||||||
|
// Tournaments
|
||||||
|
(get_upcoming_tournaments)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,4 @@ add_subdirectory( witness )
|
||||||
add_subdirectory( account_history )
|
add_subdirectory( account_history )
|
||||||
add_subdirectory( market_history )
|
add_subdirectory( market_history )
|
||||||
add_subdirectory( delayed_node )
|
add_subdirectory( delayed_node )
|
||||||
|
add_subdirectory( generate_genesis )
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue