Fix #385 - HARDFORK to expand valid names
This commit is contained in:
parent
3bc8832dde
commit
ddd58e946a
4 changed files with 27 additions and 9 deletions
|
|
@ -50,7 +50,7 @@ void_result asset_create_evaluator::do_evaluate( const asset_create_operation& o
|
|||
FC_ASSERT( asset_symbol_itr == asset_indx.end() );
|
||||
|
||||
auto dotpos = op.symbol.find( '.' );
|
||||
if( dotpos != std::string::npos ) {
|
||||
if( dotpos != std::string::npos && d.head_block_time() > HARDFORK_385_TIME ) {
|
||||
auto prefix = op.symbol.substr( 0, dotpos );
|
||||
auto asset_symbol_itr = asset_indx.find( op.symbol );
|
||||
FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered",
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#define GRAPHENE_SYMBOL "BTS"
|
||||
#define GRAPHENE_ADDRESS_PREFIX "BTS"
|
||||
|
||||
#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 3
|
||||
#define GRAPHENE_MIN_ACCOUNT_NAME_LENGTH 1
|
||||
#define GRAPHENE_MAX_ACCOUNT_NAME_LENGTH 63
|
||||
|
||||
#define GRAPHENE_MIN_ASSET_SYMBOL_LENGTH 3
|
||||
|
|
|
|||
|
|
@ -22,3 +22,4 @@
|
|||
|
||||
#define HARDFORK_357_TIME (fc::time_point_sec( 1444416300 ))
|
||||
#define HARDFORK_359_TIME (fc::time_point_sec( 1444416300 ))
|
||||
#define HARDFORK_385_TIME (fc::time_point_sec( 1445558400 )) // October 23 enforce PARENT.CHILD and allow short names
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
*
|
||||
*/
|
||||
#include <graphene/chain/protocol/account.hpp>
|
||||
#include <graphene/chain/hardfork.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
|
|
@ -53,17 +54,27 @@ namespace graphene { namespace chain {
|
|||
* - Length is between (inclusive) GRAPHENE_MIN_ACCOUNT_NAME_LENGTH and GRAPHENE_MAX_ACCOUNT_NAME_LENGTH
|
||||
*/
|
||||
bool is_valid_name( const string& name )
|
||||
{
|
||||
#if GRAPHENE_MIN_ACCOUNT_NAME_LENGTH < 3
|
||||
#error This is_valid_name implementation implicitly enforces minimum name length of 3.
|
||||
#endif
|
||||
|
||||
{ try {
|
||||
const size_t len = name.size();
|
||||
|
||||
/** this condition will prevent witnesses from including new names before this time, but
|
||||
* allow them after this time. This check can be removed from the code after HARDFORK_385_TIME
|
||||
* has passed.
|
||||
*/
|
||||
if( fc::time_point::now() < fc::time_point(HARDFORK_385_TIME) )
|
||||
FC_ASSERT( len >= 3 );
|
||||
|
||||
if( len < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH )
|
||||
{
|
||||
ilog( ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
if( len > GRAPHENE_MAX_ACCOUNT_NAME_LENGTH )
|
||||
{
|
||||
ilog( ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t begin = 0;
|
||||
while( true )
|
||||
|
|
@ -71,8 +82,11 @@ bool is_valid_name( const string& name )
|
|||
size_t end = name.find_first_of( '.', begin );
|
||||
if( end == std::string::npos )
|
||||
end = len;
|
||||
if( end - begin < 3 )
|
||||
if( (end - begin) < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH )
|
||||
{
|
||||
idump( (name) (end)(len)(begin)(GRAPHENE_MAX_ACCOUNT_NAME_LENGTH) );
|
||||
return false;
|
||||
}
|
||||
switch( name[begin] )
|
||||
{
|
||||
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
|
||||
|
|
@ -81,6 +95,7 @@ bool is_valid_name( const string& name )
|
|||
case 'y': case 'z':
|
||||
break;
|
||||
default:
|
||||
ilog( ".");
|
||||
return false;
|
||||
}
|
||||
switch( name[end-1] )
|
||||
|
|
@ -93,6 +108,7 @@ bool is_valid_name( const string& name )
|
|||
case '8': case '9':
|
||||
break;
|
||||
default:
|
||||
ilog( ".");
|
||||
return false;
|
||||
}
|
||||
for( size_t i=begin+1; i<end-1; i++ )
|
||||
|
|
@ -108,6 +124,7 @@ bool is_valid_name( const string& name )
|
|||
case '-':
|
||||
break;
|
||||
default:
|
||||
ilog( ".");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -116,7 +133,7 @@ bool is_valid_name( const string& name )
|
|||
begin = end+1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} FC_CAPTURE_AND_RETHROW( (name) ) }
|
||||
|
||||
bool is_cheap_name( const string& n )
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue