diff --git a/libraries/plugins/chain/chain_plugin.cpp b/libraries/plugins/chain/chain_plugin.cpp index 425c94b0e5..45a8886e82 100644 --- a/libraries/plugins/chain/chain_plugin.cpp +++ b/libraries/plugins/chain/chain_plugin.cpp @@ -126,9 +126,7 @@ class chain_plugin_impl default_block_writer( db, app ), webserver( app.get_plugin() ), theApp( app ) - { - theApp.get_plugin().add_serialization_status( [this](){ return db.has_hardfork( HIVE_HARDFORK_1_26 ); } ); - } + {} ~chain_plugin_impl() { diff --git a/libraries/plugins/json_rpc/json_rpc_plugin.cpp b/libraries/plugins/json_rpc/json_rpc_plugin.cpp index 7cac88b8fb..455a84c254 100644 --- a/libraries/plugins/json_rpc/json_rpc_plugin.cpp +++ b/libraries/plugins/json_rpc/json_rpc_plugin.cpp @@ -237,14 +237,11 @@ namespace detail _logger->log(request, response); } - void add_serialization_status( const std::function& call ); - DECLARE_API( (get_methods) (get_signature) ) std::unique_ptr< json_rpc_logger > _logger; - std::function _check_serialization_status = [](){ return true; }; appbase::application& theApp; }; @@ -254,11 +251,6 @@ namespace detail json_rpc_plugin_impl::~json_rpc_plugin_impl() {} - void json_rpc_plugin_impl::add_serialization_status( const std::function& serialization_status ) - { - _check_serialization_status = serialization_status; - } - void json_rpc_plugin_impl::add_api_method( const string& api_name, const string& method_name, const api_method& api, const api_method_signature& sig ) { wdump((api_name)(method_name)); @@ -437,50 +429,43 @@ namespace detail { STATSD_START_TIMER( "jsonrpc", "api", method_name, 1.0f, theApp ); - if( _check_serialization_status() ) + bool _change_of_serialization_is_allowed = false; + try { - bool _change_of_serialization_is_allowed = false; - try + response.result = (*call)( func_args ); + } + catch( fc::bad_cast_exception& e ) + { + if( method_name == "network_broadcast_api.broadcast_transaction" || + method_name == "database_api.verify_authority" + ) { - response.result = (*call)( func_args ); + _change_of_serialization_is_allowed = true; } - catch( fc::bad_cast_exception& e ) + else { - if( method_name == "network_broadcast_api.broadcast_transaction" || - method_name == "database_api.verify_authority" - ) - { - _change_of_serialization_is_allowed = true; - } - else - { - throw e; - } + throw e; + } + } + catch(...) + { + auto eptr = std::current_exception(); + std::rethrow_exception( eptr ); + } + + if( _change_of_serialization_is_allowed ) + { + try + { + mode_guard guard( hive::protocol::transaction_serialization_type::legacy ); + ilog("Change of serialization( `${method_name}' ) - a legacy format is enabled now",("method_name", method_name) ); + response.result = (*call)( func_args ); } catch(...) { auto eptr = std::current_exception(); std::rethrow_exception( eptr ); } - - if( _change_of_serialization_is_allowed ) - { - try - { - mode_guard guard( hive::protocol::transaction_serialization_type::legacy ); - ilog("Change of serialization( `${method_name}' ) - a legacy format is enabled now",("method_name", method_name) ); - response.result = (*call)( func_args ); - } - catch(...) - { - auto eptr = std::current_exception(); - std::rethrow_exception( eptr ); - } - } - } - else - { - response.result = (*call)( func_args ); } } } @@ -689,11 +674,6 @@ string json_rpc_plugin::call( const string& message ) } -void json_rpc_plugin::add_serialization_status( const std::function& serialization_status ) -{ - my->add_serialization_status( serialization_status ); -} - } } } // hive::plugins::json_rpc FC_REFLECT( hive::plugins::json_rpc::detail::json_rpc_error, (code)(message)(data) )