Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor code style changes and typos in account.cpp #2007

Merged
merged 3 commits into from Sep 24, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
138 changes: 66 additions & 72 deletions libraries/protocol/account.cpp
Expand Up @@ -59,71 +59,71 @@ namespace graphene { namespace protocol {
*/
bool is_valid_name( const string& name )
{ try {
const size_t len = name.size();
const size_t len = name.size();

if( len < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH )
{
return false;
}
if( len < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH )
{
return false;
abitmore marked this conversation as resolved.
Show resolved Hide resolved
}

if( len > GRAPHENE_MAX_ACCOUNT_NAME_LENGTH )
{
return false;
}
if( len > GRAPHENE_MAX_ACCOUNT_NAME_LENGTH )
{
return false;
}

size_t begin = 0;
while( true )
{
size_t end = name.find_first_of( '.', begin );
if( end == std::string::npos )
end = len;
if( (end - begin) < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH )
{
return false;
}
switch( name[begin] )
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
break;
default:
return false;
}
switch( name[end-1] )
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7':
case '8': case '9':
break;
default:
return false;
}
for( size_t i=begin+1; i<end-1; i++ )
{
switch( name[i] )
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7':
case '8': case '9':
case '-':
break;
default:
return false;
}
}
if( end == len )
break;
begin = end+1;
}
return true;
size_t begin = 0;
while( true )
{
size_t end = name.find_first_of( '.', begin );
if( end == std::string::npos )
end = len;
if( (end - begin) < GRAPHENE_MIN_ACCOUNT_NAME_LENGTH )
{
return false;
}
switch( name[begin] )
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
break;
default:
return false;
}
switch( name[end-1] )
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7':
case '8': case '9':
break;
default:
return false;
}
for( size_t i=begin+1; i<end-1; i++ )
{
switch( name[i] )
{
case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h':
case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p':
case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x':
case 'y': case 'z':
case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7':
case '8': case '9':
case '-':
break;
default:
return false;
}
}
if( end == len )
break;
begin = end+1;
}
return true;
} FC_CAPTURE_AND_RETHROW( (name) ) }

bool is_cheap_name( const string& n )
Expand Down Expand Up @@ -178,7 +178,6 @@ share_type account_create_operation::calculate_fee( const fee_parameters_type& k
return core_fee_required;
}


void account_create_operation::validate()const
{
FC_ASSERT( fee.amount >= 0 );
Expand All @@ -188,8 +187,8 @@ void account_create_operation::validate()const
FC_ASSERT( owner.address_auths.size() == 0 );
FC_ASSERT( active.num_auths() != 0 );
FC_ASSERT( active.address_auths.size() == 0 );
FC_ASSERT( !owner.is_impossible(), "cannot create an account with an imposible owner authority threshold" );
FC_ASSERT( !active.is_impossible(), "cannot create an account with an imposible active authority threshold" );
FC_ASSERT( !owner.is_impossible(), "cannot create an account with an impossible owner authority threshold" );
FC_ASSERT( !active.is_impossible(), "cannot create an account with an impossible active authority threshold" );
options.validate();
if( extensions.value.owner_special_authority.valid() )
validate_special_authority( *extensions.value.owner_special_authority );
Expand All @@ -210,9 +209,6 @@ void account_create_operation::validate()const
}
}




share_type account_update_operation::calculate_fee( const fee_parameters_type& k )const
{
auto core_fee_required = k.fee;
Expand Down Expand Up @@ -241,13 +237,13 @@ void account_update_operation::validate()const
{
FC_ASSERT( owner->num_auths() != 0 );
FC_ASSERT( owner->address_auths.size() == 0 );
FC_ASSERT( !owner->is_impossible(), "cannot update an account with an imposible owner authority threshold" );
FC_ASSERT( !owner->is_impossible(), "cannot update an account with an impossible owner authority threshold" );
}
if( active )
{
FC_ASSERT( active->num_auths() != 0 );
FC_ASSERT( active->address_auths.size() == 0 );
FC_ASSERT( !active->is_impossible(), "cannot update an account with an imposible active authority threshold" );
FC_ASSERT( !active->is_impossible(), "cannot update an account with an impossible active authority threshold" );
}

if( new_options )
Expand All @@ -265,7 +261,6 @@ share_type account_upgrade_operation::calculate_fee(const fee_parameters_type& k
return k.membership_annual_fee;
}


void account_upgrade_operation::validate() const
{
FC_ASSERT( fee.amount >= 0 );
Expand All @@ -276,7 +271,6 @@ void account_transfer_operation::validate()const
FC_ASSERT( fee.amount >= 0 );
}


} } // graphene::protocol

GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION( graphene::protocol::account_options )
Expand Down