Skip to content

Commit

Permalink
Use fixed_string for custom operation ID fields #3170
Browse files Browse the repository at this point in the history
  • Loading branch information
theoreticalbts committed Nov 20, 2018
1 parent 55a2797 commit fe2938a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/include/steem/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libraries/protocol/include/steem/protocol/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ namespace steem {
typedef safe<int64_t> share_type;
typedef uint16_t weight_type;
typedef uint32_t contribution_id_type;
typedef fixed_string<32> custom_id_type;


struct public_key_type
Expand Down

0 comments on commit fe2938a

Please sign in to comment.