-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert changes to name, except for removal of N()
- Loading branch information
Showing
2 changed files
with
22 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
#include <eosio/chain/name.hpp> | ||
#include <fc/variant.hpp> | ||
#include <boost/algorithm/string.hpp> | ||
#include <fc/exception/exception.hpp> | ||
#include <eosio/chain/exceptions.hpp> | ||
|
||
namespace eosio::chain { | ||
|
||
void name::set( std::string_view str ) { | ||
const auto len = str.size(); | ||
EOS_ASSERT(len <= 13, name_type_exception, "Name is longer than 13 characters (${name}) ", ("name", std::string(str))); | ||
value = string_to_uint64_t(str); | ||
EOS_ASSERT(to_string() == str, name_type_exception, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
tbfleming
Contributor
|
||
"Name not properly normalized (name: ${name}, normalized: ${normalized}) ", | ||
("name", std::string(str))("normalized", to_string())); | ||
} | ||
|
||
// keep in sync with name::to_string() in contract definition for name | ||
|
@@ -25,32 +32,6 @@ namespace eosio::chain { | |
return str; | ||
} | ||
|
||
bool is_string_valid_name(std::string_view str) | ||
{ | ||
size_t slen = str.size(); | ||
if( slen > 13) | ||
return false; | ||
|
||
size_t len = (slen <= 12) ? slen : 12; | ||
for( size_t i = 0; i < len; ++i ) { | ||
char c = str[i]; | ||
if ((c >= 'a' && c <= 'z') || (c >= '1' && c <= '5') || (c == '.')) | ||
continue; | ||
else | ||
return false; | ||
} | ||
|
||
if( slen == 13) { | ||
char c = str[12]; | ||
if ((c >= 'a' && c <= 'j') || (c >= '1' && c <= '5') || (c == '.')) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} // eosio::chain | ||
|
||
namespace fc { | ||
|
Name conversion is critical for Eos. I'm worried about this change will hurt the performance significantly.