From 342e33008ca4f1f3142b8660b027078cb8c766e5 Mon Sep 17 00:00:00 2001 From: elmato Date: Fri, 3 Feb 2017 19:25:52 +0000 Subject: [PATCH] Restore bloom filter usage: Check if the object changed/removed was previously subscribed (read) before sending updates back to ws clients --- libraries/app/database_api.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index b811ebcd..f296005a 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -160,7 +160,7 @@ class database_api_impl : public std::enable_shared_from_this { if( !_subscribe_callback ) return false; - return true; + return _subscribe_filter.contains( i ); } @@ -1818,8 +1818,10 @@ void database_api_impl::on_objects_removed( const vector& objs ) vector updates; updates.reserve(objs.size()); - for( auto obj : objs ) - updates.emplace_back( obj->id ); + for( auto obj : objs ) { + if ( is_subscribed_to_item(obj->id) ) + updates.emplace_back( obj->id ); + } broadcast_updates( updates ); } @@ -1859,7 +1861,7 @@ void database_api_impl::on_objects_changed(const vector& ids) for(auto id : ids) { const object* obj = nullptr; - if( _subscribe_callback ) + if( is_subscribed_to_item(id) ) { obj = _db.find_object( id ); if( obj ) @@ -1874,7 +1876,7 @@ void database_api_impl::on_objects_changed(const vector& ids) if( _market_subscriptions.size() ) { - if( !_subscribe_callback ) + if( !is_subscribed_to_item(id) ) obj = _db.find_object( id ); if( obj ) { @@ -1895,7 +1897,7 @@ void database_api_impl::on_objects_changed(const vector& ids) /// if a connection hangs then this could get backed up and result in /// a failure to exit cleanly. fc::async([capture_this,this,updates,market_broadcast_queue](){ - if( _subscribe_callback ) _subscribe_callback( updates ); + if( _subscribe_callback && updates.size() ) _subscribe_callback( updates ); for( const auto& item : market_broadcast_queue ) {