From fe2938a9d31339e16a99a91c720bb7a5c471252d Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Tue, 20 Nov 2018 16:10:39 -0500 Subject: [PATCH] Use fixed_string for custom operation ID fields #3170 --- libraries/chain/database.cpp | 2 +- libraries/chain/include/steem/chain/database.hpp | 4 ++-- .../protocol/include/steem/protocol/steem_operations.hpp | 4 ++-- libraries/protocol/include/steem/protocol/types.hpp | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/chain/database.cpp b/libraries/chain/database.cpp index 725dc5c87f..09db17418d 100644 --- a/libraries/chain/database.cpp +++ b/libraries/chain/database.cpp @@ -2597,7 +2597,7 @@ void database::set_custom_operation_interpreter( const std::string& id, std::sha FC_ASSERT( inserted ); } -std::shared_ptr< custom_operation_interpreter > database::get_custom_json_evaluator( const std::string& id ) +std::shared_ptr< custom_operation_interpreter > database::get_custom_json_evaluator( const custom_id_type& id ) { auto it = _custom_operation_interpreters.find( id ); if( it != _custom_operation_interpreters.end() ) diff --git a/libraries/chain/include/steem/chain/database.hpp b/libraries/chain/include/steem/chain/database.hpp index bc2923c967..1c9f555471 100644 --- a/libraries/chain/include/steem/chain/database.hpp +++ b/libraries/chain/include/steem/chain/database.hpp @@ -426,7 +426,7 @@ namespace steem { namespace chain { void initialize_evaluators(); void set_custom_operation_interpreter( const std::string& id, std::shared_ptr< custom_operation_interpreter > registry ); - std::shared_ptr< custom_operation_interpreter > get_custom_json_evaluator( const std::string& id ); + std::shared_ptr< custom_operation_interpreter > get_custom_json_evaluator( const custom_id_type& id ); /// Reset the object graph in-memory void initialize_indexes(); @@ -585,7 +585,7 @@ namespace steem { namespace chain { uint16_t _shared_file_full_threshold = 0; uint16_t _shared_file_scale_rate = 0; - flat_map< std::string, std::shared_ptr< custom_operation_interpreter > > _custom_operation_interpreters; + flat_map< custom_id_type, std::shared_ptr< custom_operation_interpreter > > _custom_operation_interpreters; std::string _json_schema; util::advanced_benchmark_dumper _benchmark_dumper; diff --git a/libraries/protocol/include/steem/protocol/steem_operations.hpp b/libraries/protocol/include/steem/protocol/steem_operations.hpp index 0233b422af..4150002e51 100644 --- a/libraries/protocol/include/steem/protocol/steem_operations.hpp +++ b/libraries/protocol/include/steem/protocol/steem_operations.hpp @@ -571,7 +571,7 @@ namespace steem { namespace protocol { { flat_set< account_name_type > required_auths; flat_set< account_name_type > required_posting_auths; - string id; ///< must be less than 32 characters long + custom_id_type id; ///< must be less than 32 characters long string json; ///< must be proper utf8 / JSON string. void validate()const; @@ -587,7 +587,7 @@ namespace steem { namespace protocol { flat_set< account_name_type > required_posting_auths; vector< authority > required_auths; - string id; ///< must be less than 32 characters long + custom_id_type id; ///< must be less than 32 characters long vector< char > data; void validate()const; diff --git a/libraries/protocol/include/steem/protocol/types.hpp b/libraries/protocol/include/steem/protocol/types.hpp index 3a60b15e97..d6665a5f04 100644 --- a/libraries/protocol/include/steem/protocol/types.hpp +++ b/libraries/protocol/include/steem/protocol/types.hpp @@ -80,6 +80,7 @@ namespace steem { typedef safe share_type; typedef uint16_t weight_type; typedef uint32_t contribution_id_type; + typedef fixed_string<32> custom_id_type; struct public_key_type