diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index 35cf3880..af434518 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -211,6 +212,7 @@ namespace graphene { namespace app { return *_crypto_api; } +#if 0 vector get_relevant_accounts( const object* obj ) { vector result; @@ -292,6 +294,14 @@ namespace graphene { namespace app { } case balance_object_type:{ /** these are free from any accounts */ break; + } case tournament_object_type:{ + const tournament_object* tournament_obj = dynamic_cast(obj); + assert(tournament_obj); + const tournament_details_object& details = tournament_obj->tournament_details_id(*_app.chain_database()); + flat_set 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; } // end get_relevant_accounts( obj ) +#endif vector history_api::get_fill_order_history( asset_id_type a, asset_id_type b, uint32_t limit )const { diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index 0e57ef7f..a00da930 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -137,6 +138,9 @@ class database_api_impl : public std::enable_shared_from_this // Blinded balances vector get_blinded_balances( const flat_set& commitments )const; + // Tournaments + vector get_upcoming_tournaments(fc::optional account_filter)const; + //private: template void subscribe_to_item( const T& i )const @@ -1758,6 +1762,30 @@ vector database_api_impl::get_blinded_balances( const fl return result; } +////////////////////////////////////////////////////////////////////// +// // +// Tournament methods // +// // +////////////////////////////////////////////////////////////////////// + +vector database_api::get_upcoming_tournaments(fc::optional account_filter)const +{ + return my->get_upcoming_tournaments(account_filter); +} + +vector database_api_impl::get_upcoming_tournaments(fc::optional account_filter)const +{ + vector result; + const auto& registration_deadline_index = _db.get_index_type().indices().get(); + 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 // diff --git a/libraries/app/include/graphene/app/database_api.hpp b/libraries/app/include/graphene/app/database_api.hpp index 456e0bae..8d671a42 100644 --- a/libraries/app/include/graphene/app/database_api.hpp +++ b/libraries/app/include/graphene/app/database_api.hpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -548,6 +549,16 @@ class database_api */ vector get_blinded_balances( const flat_set& 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 get_upcoming_tournaments(fc::optional account_filter)const; + private: std::shared_ptr< database_api_impl > my; }; @@ -648,4 +659,7 @@ FC_API(graphene::app::database_api, // Blinded balances (get_blinded_balances) + + // Tournaments + (get_upcoming_tournaments) ) diff --git a/libraries/plugins/CMakeLists.txt b/libraries/plugins/CMakeLists.txt index 128d8aa1..328162fe 100644 --- a/libraries/plugins/CMakeLists.txt +++ b/libraries/plugins/CMakeLists.txt @@ -2,3 +2,4 @@ add_subdirectory( witness ) add_subdirectory( account_history ) add_subdirectory( market_history ) add_subdirectory( delayed_node ) +add_subdirectory( generate_genesis )