diff --git a/libraries/app/api.cpp b/libraries/app/api.cpp index b8325ced..62ec8681 100644 --- a/libraries/app/api.cpp +++ b/libraries/app/api.cpp @@ -288,7 +288,6 @@ namespace graphene { namespace app { }); results[account_name_or_id] = acnt; } - wdump((results)); return results; } @@ -709,7 +708,6 @@ namespace graphene { namespace app { result.push_back( aobj->owner ); break; } case impl_account_statistics_object_type:{ - elog( "stats object" ); const auto& aobj = dynamic_cast(obj); assert( aobj != nullptr ); result.push_back( aobj->owner ); @@ -760,7 +758,6 @@ namespace graphene { namespace app { _broadcast_removed_complete = fc::async([=](){ for( const auto& item : broadcast_queue ) { - idump((item.first)(item.second) ); auto sub = _account_subscriptions.find(item.first); if( sub != _account_subscriptions.end() ) sub->second( fc::variant(item.second ) ); @@ -797,13 +794,11 @@ namespace graphene { namespace app { void database_api::on_objects_changed(const vector& ids) { - idump((ids)(_account_subscriptions.size())); vector my_objects; map > broadcast_queue; map< pair, vector > market_broadcast_queue; for(auto id : ids) { - edump((id)(_account_subscriptions.size())); if(_subscriptions.find(id) != _subscriptions.end()) my_objects.push_back(id); @@ -814,7 +809,6 @@ namespace graphene { namespace app { if( obj ) { vector relevant = get_relevant_accounts( obj ); - edump(("relevant accounts")(relevant)(obj->id)); for( const auto& r : relevant ) { auto sub = _account_subscriptions.find(r); @@ -848,9 +842,6 @@ namespace graphene { namespace app { /// if a connection hangs then this could get backed up and result in /// a failure to exit cleanly. _broadcast_changes_complete = fc::async([=](){ - for( const auto& item : broadcast_queue ) - edump((item.second)); - for( const auto& item : broadcast_queue ) { edump( (item) ); @@ -932,11 +923,11 @@ namespace graphene { namespace app { } - bool database_api::subscribe_to_objects( const std::function& callback, const vector& ids) + vector database_api::subscribe_to_objects( const std::function& callback, const vector& ids) { FC_ASSERT( _subscriptions.size() < 1024 ); for(auto id : ids) _subscriptions[id] = callback; - return true; + return get_objects( ids ); } bool database_api::unsubscribe_from_objects(const vector& ids) diff --git a/libraries/app/include/graphene/app/api.hpp b/libraries/app/include/graphene/app/api.hpp index 58d683eb..f22534b8 100644 --- a/libraries/app/include/graphene/app/api.hpp +++ b/libraries/app/include/graphene/app/api.hpp @@ -251,8 +251,9 @@ namespace graphene { namespace app { * @brief Request notifications when some object(s) change * @param callback Callback method which is called with the new version of a changed object * @param ids The set of object IDs to watch + * @return get_objects(ids) */ - bool subscribe_to_objects(const std::function& callback, + vector subscribe_to_objects(const std::function& callback, const vector& ids); /** * @brief Stop receiving notifications for some object(s) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index 9b1e6bda..5f7960b3 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -85,9 +85,6 @@ void_result account_create_evaluator::do_evaluate( const account_create_operatio object_id_type account_create_evaluator::do_apply( const account_create_operation& o ) { try { - const auto& stats_obj = db().create( [&]( account_statistics_object& ){ - }); - const auto& new_acnt_object = db().create( [&]( account_object& obj ){ obj.registrar = o.registrar; obj.referrer = o.referrer; @@ -101,8 +98,8 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio obj.name = o.name; obj.owner = o.owner; obj.active = o.active; - obj.statistics = stats_obj.id; obj.options = o.options; + obj.statistics = db().create([&](account_statistics_object& s){s.owner = obj.id;}).id; }); const auto& dynamic_properties = db().get_dynamic_global_properties(); diff --git a/libraries/chain/db_init.cpp b/libraries/chain/db_init.cpp index 88adb318..635dbb80 100644 --- a/libraries/chain/db_init.cpp +++ b/libraries/chain/db_init.cpp @@ -234,12 +234,12 @@ void database::init_genesis(const genesis_state_type& genesis_state) n.owner.weight_threshold = 1; n.active.weight_threshold = 1; n.name = "committee-account"; - n.statistics = create( [&](account_statistics_object& b){}).id; + n.statistics = create( [&](account_statistics_object& s){ s.owner = n.id; }).id; }); FC_ASSERT(committee_account.get_id() == GRAPHENE_COMMITTEE_ACCOUNT); FC_ASSERT(create([this](account_object& a) { a.name = "witness-account"; - a.statistics = create([](account_statistics_object&){}).id; + a.statistics = create([&](account_statistics_object& s){s.owner = a.id;}).id; a.owner.weight_threshold = 1; a.active.weight_threshold = 1; a.registrar = a.lifetime_referrer = a.referrer = GRAPHENE_WITNESS_ACCOUNT; @@ -249,7 +249,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) }).get_id() == GRAPHENE_WITNESS_ACCOUNT); FC_ASSERT(create([this](account_object& a) { a.name = "relaxed-committee-account"; - a.statistics = create([](account_statistics_object&){}).id; + a.statistics = create([&](account_statistics_object& s){s.owner = a.id;}).id; a.owner.weight_threshold = 1; a.active.weight_threshold = 1; a.registrar = a.lifetime_referrer = a.referrer = GRAPHENE_RELAXED_COMMITTEE_ACCOUNT; @@ -259,7 +259,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) }).get_id() == GRAPHENE_RELAXED_COMMITTEE_ACCOUNT); FC_ASSERT(create([this](account_object& a) { a.name = "null-account"; - a.statistics = create([](account_statistics_object&){}).id; + a.statistics = create([&](account_statistics_object& s){s.owner = a.id;}).id; a.owner.weight_threshold = 1; a.active.weight_threshold = 1; a.registrar = a.lifetime_referrer = a.referrer = GRAPHENE_NULL_ACCOUNT; @@ -269,7 +269,7 @@ void database::init_genesis(const genesis_state_type& genesis_state) }).get_id() == GRAPHENE_NULL_ACCOUNT); FC_ASSERT(create([this](account_object& a) { a.name = "temp-account"; - a.statistics = create([](account_statistics_object&){}).id; + a.statistics = create([&](account_statistics_object& s){s.owner = a.id;}).id; a.owner.weight_threshold = 0; a.active.weight_threshold = 0; a.registrar = a.lifetime_referrer = a.referrer = GRAPHENE_TEMP_ACCOUNT;