Commit 295ea984 authored by Mariusz's avatar Mariusz Committed by Mariusz
Browse files

Some fixes/preparations

parent a85cab38
......@@ -356,8 +356,8 @@ namespace detail
{
if( method_name == "network_broadcast_api.broadcast_transaction" )
{
legacy_switcher switcher( true );
ilog("Change of serialization - a legacy is enabled now");
legacy_switcher switcher;
ilog("Change of serialization( `network_broadcast_api.broadcast_transaction' ) - ${format} is enabled now", ("format", legacy_switcher::info()) );
response.result = (*call)( func_args );
}
else
......
......@@ -18,6 +18,7 @@ enum curve_id
struct dynamic_serializer
{
static const bool default_legacy_value = false;
/*
This switch is used for switching of serialization.
*/
......@@ -26,10 +27,13 @@ struct dynamic_serializer
struct legacy_switcher
{
const bool old_legacy_enabled = false;
const bool old_legacy_enabled = dynamic_serializer::default_legacy_value;
legacy_switcher();
legacy_switcher( bool val );
~legacy_switcher();
static std::string info();
};
std::string trim_legacy_typename_namespace( const std::string& name );
......@@ -62,7 +66,6 @@ namespace fc {
{
try
{
legacy_switcher switcher( true );
to_variant( a.value, var );
} FC_CAPTURE_AND_RETHROW()
}
......
......@@ -2,7 +2,12 @@
namespace hive { namespace protocol {
thread_local bool dynamic_serializer::legacy_enabled = false;
thread_local bool dynamic_serializer::legacy_enabled = dynamic_serializer::default_legacy_value;
legacy_switcher::legacy_switcher() : old_legacy_enabled( dynamic_serializer::legacy_enabled )
{
dynamic_serializer::legacy_enabled = !dynamic_serializer::legacy_enabled;
}
legacy_switcher::legacy_switcher( bool val ) : old_legacy_enabled( dynamic_serializer::legacy_enabled )
{
......@@ -14,6 +19,11 @@ legacy_switcher::~legacy_switcher()
dynamic_serializer::legacy_enabled = old_legacy_enabled;
}
std::string legacy_switcher::info()
{
return dynamic_serializer::legacy_enabled ? "a legacy format" : "non legacy format";
}
std::string trim_legacy_typename_namespace( const std::string& name )
{
auto start = name.find_last_of( ':' ) + 1;
......
......@@ -91,7 +91,7 @@ class wallet_api
{
public:
wallet_api( const wallet_data& initial_data, const chain_id_type& _hive_chain_id,
const fc::api< hive::plugins::wallet_bridge_api::wallet_bridge_api >& remote_api, fc::promise< int >::ptr& exit_promise, bool is_daemon, format_type _format, bool _legacy_format );
const fc::api< hive::plugins::wallet_bridge_api::wallet_bridge_api >& remote_api, fc::promise< int >::ptr& exit_promise, bool is_daemon, format_type _format, bool legacy_format );
virtual ~wallet_api();
bool copy_wallet_file( const string& destination_filename );
......
......@@ -233,8 +233,8 @@ class wallet_api_impl
public:
wallet_api& self;
wallet_api_impl( wallet_api& s, const wallet_data& initial_data, const chain_id_type& hive_chain_id, const fc::api< hive::plugins::wallet_bridge_api::wallet_bridge_api >& remote_api )
: self( s ), _wallet( initial_data ), _hive_chain_id( hive_chain_id ), _remote_wallet_bridge_api(remote_api)
wallet_api_impl( wallet_api& s, const wallet_data& initial_data, const chain_id_type& hive_chain_id, const fc::api< hive::plugins::wallet_bridge_api::wallet_bridge_api >& remote_api, bool legacy_format )
: self( s ), _wallet( initial_data ), _hive_chain_id( hive_chain_id ), _remote_wallet_bridge_api(remote_api), _legacy_format( legacy_format )
{
init_prototype_ops();
}
......@@ -939,6 +939,8 @@ public:
authorities_type _authorities_to_use;
bool _use_automatic_authority = true;
bool _legacy_format = dynamic_serializer::default_legacy_value;
#ifdef __unix__
mode_t _old_umask;
#endif
......@@ -972,10 +974,9 @@ serializer_wrapper<annotated_signed_transaction> wallet_api_impl::build_claim_ac
namespace hive { namespace wallet {
wallet_api::wallet_api(const wallet_data& initial_data, const chain_id_type& hive_chain_id,
const fc::api< hive::plugins::wallet_bridge_api::wallet_bridge_api >& remote_api, fc::promise< int >::ptr& exit_promise, bool is_daemon, format_type _format, bool _legacy_format )
: my(new detail::wallet_api_impl(*this, initial_data, hive_chain_id, remote_api)), exit_promise(exit_promise), is_daemon(is_daemon), format(_format)
const fc::api< hive::plugins::wallet_bridge_api::wallet_bridge_api >& remote_api, fc::promise< int >::ptr& exit_promise, bool is_daemon, format_type _format, bool legacy_format )
: my(new detail::wallet_api_impl(*this, initial_data, hive_chain_id, remote_api, legacy_format)), exit_promise(exit_promise), is_daemon(is_daemon), format(_format)
{
hive::protocol::dynamic_serializer::legacy_enabled = _legacy_format;
}
wallet_api::~wallet_api(){}
......
......@@ -104,7 +104,7 @@ int main( int argc, char** argv )
("wallet-file,w", bpo::value<string>()->implicit_value("wallet.json"), "Wallet to load")
("chain-id", bpo::value< std::string >()->default_value( HIVE_CHAIN_ID ), "Chain ID to connect to")
("format-type", bpo::value< std::string >(), "Allows to change formatting for functions that require special formatting" )
("legacy-format", bpo::value< bool >()->default_value( true ), "Allows to generate JSON using legacy/non legacy format. By default is true." )
("legacy-format", bpo::value< bool >()->default_value( dynamic_serializer::legacy_enabled ), "Allows to generate JSON using legacy/non legacy format. By default is true." )
;
vector<string> allowed_ips;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment