Skip to content

Commit

Permalink
Apply retrograde formatting
Browse files Browse the repository at this point in the history
It was inconsistent before, and it's inconsistent now, but now it's
inconsistently ugly rather than inconsistently better.
  • Loading branch information
nathanielhourt committed Mar 13, 2019
1 parent 06e9090 commit b78ccaf
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 253 deletions.
74 changes: 37 additions & 37 deletions libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2058,71 +2058,71 @@ set<address> database_api::get_potential_address_signatures( const signed_transa
return my->get_potential_address_signatures( trx );
}

set<public_key_type> database_api_impl::get_potential_signatures(const signed_transaction& trx) const
set<public_key_type> database_api_impl::get_potential_signatures( const signed_transaction& trx )const
{
auto chain_time = _db.head_block_time();
bool allow_non_immediate_owner = (chain_time >= HARDFORK_CORE_584_TIME);
bool ignore_custom_op_reqd_auths = MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time);
bool allow_non_immediate_owner = ( chain_time >= HARDFORK_CORE_584_TIME );
bool ignore_custom_op_reqd_auths = MUST_IGNORE_CUSTOM_OP_REQD_AUTHS( chain_time );

set<public_key_type> result;
auto get_active = [this, &result](account_id_type id) {
const auto& auth = id(_db).active;
for (const auto& k : auth.get_keys())
result.insert(k);
auto get_active = [this, &result]( account_id_type id ){
const auto& auth = id( _db ).active;
for( const auto& k : auth.get_keys() )
result.insert( k );
return &auth;
};
auto get_owner = [this, &result](account_id_type id) {
const auto& auth = id(_db).owner;
for (const auto& k : auth.get_keys())
result.insert(k);
auto get_owner = [this, &result]( account_id_type id ){
const auto& auth = id( _db ).owner;
for( const auto& k : auth.get_keys() )
result.insert( k );
return &auth;
};

trx.get_required_signatures(_db.get_chain_id(),
flat_set<public_key_type>(),
get_active, get_owner,
allow_non_immediate_owner,
ignore_custom_op_reqd_auths,
_db.get_global_properties().parameters.max_authority_depth);
trx.get_required_signatures( _db.get_chain_id(),
flat_set<public_key_type>(),
get_active, get_owner,
allow_non_immediate_owner,
ignore_custom_op_reqd_auths,
_db.get_global_properties().parameters.max_authority_depth );

// Insert keys in required "other" authories
flat_set<account_id_type> required_active;
flat_set<account_id_type> required_owner;
vector<authority> other;
trx.get_required_authorities(required_active, required_owner, other, ignore_custom_op_reqd_auths);
for (const auto& auth : other)
for (const auto& key : auth.get_keys())
result.insert(key);
trx.get_required_authorities( required_active, required_owner, other, ignore_custom_op_reqd_auths );
for( const auto& auth : other )
for( const auto& key : auth.get_keys() )
result.insert( key );

return result;
}

set<address> database_api_impl::get_potential_address_signatures(const signed_transaction& trx)const
set<address> database_api_impl::get_potential_address_signatures( const signed_transaction& trx )const
{
auto chain_time = _db.head_block_time();
bool allow_non_immediate_owner = (chain_time >= HARDFORK_CORE_584_TIME);
bool ignore_custom_op_reqd_auths = MUST_IGNORE_CUSTOM_OP_REQD_AUTHS(chain_time);
bool allow_non_immediate_owner = ( chain_time >= HARDFORK_CORE_584_TIME );
bool ignore_custom_op_reqd_auths = MUST_IGNORE_CUSTOM_OP_REQD_AUTHS( chain_time );

set<address> result;
auto get_active = [this, &result](account_id_type id) {
const auto& auth = id(_db).active;
for (const auto& k : auth.get_addresses())
result.insert(k);
auto get_active = [this, &result]( account_id_type id ){
const auto& auth = id( _db ).active;
for( const auto& k : auth.get_addresses() )
result.insert( k );
return &auth;
};
auto get_owner = [this, &result](account_id_type id) {
const auto& auth = id(_db).owner;
auto get_owner = [this, &result]( account_id_type id ) {
const auto& auth = id( _db ).owner;
for (const auto& k : auth.get_addresses())
result.insert(k);
result.insert( k );
return &auth;
};

trx.get_required_signatures(_db.get_chain_id(),
flat_set<public_key_type>(),
get_active, get_owner,
allow_non_immediate_owner,
ignore_custom_op_reqd_auths,
_db.get_global_properties().parameters.max_authority_depth);
trx.get_required_signatures( _db.get_chain_id(),
flat_set<public_key_type>(),
get_active, get_owner,
allow_non_immediate_owner,
ignore_custom_op_reqd_auths,
_db.get_global_properties().parameters.max_authority_depth );
return result;
}

Expand Down
38 changes: 19 additions & 19 deletions libraries/chain/db_notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ struct get_impacted_account_visitor
flat_set<account_id_type>& _impacted;
bool _ignore_custom_op_reqd_auths;

get_impacted_account_visitor(flat_set<account_id_type>& impact, bool ignore_custom_operation_required_auths)
: _impacted(impact), _ignore_custom_op_reqd_auths(ignore_custom_operation_required_auths)
get_impacted_account_visitor( flat_set<account_id_type>& impact, bool ignore_custom_operation_required_auths )
: _impacted( impact ), _ignore_custom_op_reqd_auths( ignore_custom_operation_required_auths )
{}

using result_type = void;
Expand Down Expand Up @@ -157,10 +157,10 @@ struct get_impacted_account_visitor
{
_impacted.insert( op.fee_payer() ); // fee_paying_account
vector<authority> other;
for (const auto& proposed_op : op.proposed_ops)
operation_get_required_authorities(proposed_op.op, _impacted, _impacted, other, _ignore_custom_op_reqd_auths);
for (auto& o : other)
add_authority_accounts(_impacted, o);
for( const auto& proposed_op : op.proposed_ops )
operation_get_required_authorities( proposed_op.op, _impacted, _impacted, other, _ignore_custom_op_reqd_auths );
for( auto& o : other )
add_authority_accounts( _impacted, o );
}
void operator()( const proposal_update_operation& op )
{
Expand Down Expand Up @@ -287,17 +287,17 @@ struct get_impacted_account_visitor
}
};

void graphene::chain::operation_get_impacted_accounts(const operation& op, flat_set<account_id_type>& result, bool ignore_custom_operation_required_auths) {
get_impacted_account_visitor vtor = get_impacted_account_visitor(result, ignore_custom_operation_required_auths);
op.visit(vtor);
void graphene::chain::operation_get_impacted_accounts( const operation& op, flat_set<account_id_type>& result, bool ignore_custom_operation_required_auths ) {
get_impacted_account_visitor vtor = get_impacted_account_visitor( result, ignore_custom_operation_required_auths );
op.visit( vtor );
}

void graphene::chain::transaction_get_impacted_accounts(const transaction& tx, flat_set<account_id_type>& result, bool ignore_custom_operation_required_auths) {
for (const auto& op : tx.operations)
void graphene::chain::transaction_get_impacted_accounts( const transaction& tx, flat_set<account_id_type>& result, bool ignore_custom_operation_required_auths ) {
for( const auto& op : tx.operations )
operation_get_impacted_accounts(op, result, ignore_custom_operation_required_auths);
}

void get_relevant_accounts(const object* obj, flat_set<account_id_type>& accounts, bool ignore_custom_operation_required_auths) {
void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accounts, bool ignore_custom_operation_required_auths ) {
if( obj->id.space() == protocol_ids )
{
switch( (object_type)obj->id.type() )
Expand Down Expand Up @@ -344,14 +344,14 @@ void get_relevant_accounts(const object* obj, flat_set<account_id_type>& account
} case proposal_object_type:{
const auto& aobj = dynamic_cast<const proposal_object*>(obj);
FC_ASSERT( aobj != nullptr );
transaction_get_impacted_accounts(aobj->proposed_transaction, accounts,
ignore_custom_operation_required_auths);
transaction_get_impacted_accounts( aobj->proposed_transaction, accounts,
ignore_custom_operation_required_auths );
break;
} case operation_history_object_type:{
const auto& aobj = dynamic_cast<const operation_history_object*>(obj);
FC_ASSERT( aobj != nullptr );
operation_get_impacted_accounts(aobj->op, accounts,
ignore_custom_operation_required_auths);
operation_get_impacted_accounts( aobj->op, accounts,
ignore_custom_operation_required_auths );
break;
} case withdraw_permission_object_type:{
const auto& aobj = dynamic_cast<const withdraw_permission_object*>(obj);
Expand Down Expand Up @@ -408,8 +408,8 @@ void get_relevant_accounts(const object* obj, flat_set<account_id_type>& account
} case impl_transaction_object_type:{
const auto& aobj = dynamic_cast<const transaction_object*>(obj);
FC_ASSERT( aobj != nullptr );
transaction_get_impacted_accounts(aobj->trx, accounts,
ignore_custom_operation_required_auths);
transaction_get_impacted_accounts( aobj->trx, accounts,
ignore_custom_operation_required_auths );
break;
} case impl_blinded_balance_object_type:{
const auto& aobj = dynamic_cast<const blinded_balance_object*>(obj);
Expand Down Expand Up @@ -515,7 +515,7 @@ void database::notify_changed_objects()
}

if( removed_ids.size() )
GRAPHENE_TRY_NOTIFY(removed_objects, removed_ids, removed, removed_accounts_impacted)
GRAPHENE_TRY_NOTIFY( removed_objects, removed_ids, removed, removed_accounts_impacted )
}
}
} FC_CAPTURE_AND_LOG( (0) ) }
Expand Down
12 changes: 6 additions & 6 deletions libraries/chain/include/graphene/chain/impacted.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

namespace graphene { namespace chain {

void operation_get_impacted_accounts(const graphene::chain::operation& op,
fc::flat_set<graphene::chain::account_id_type>& result,
bool ignore_custom_operation_required_auths);
void operation_get_impacted_accounts( const graphene::chain::operation& op,
fc::flat_set<graphene::chain::account_id_type>& result,
bool ignore_custom_operation_required_auths );

void transaction_get_impacted_accounts(const graphene::chain::transaction& tx,
fc::flat_set<graphene::chain::account_id_type>& result,
bool ignore_custom_operation_required_auths);
void transaction_get_impacted_accounts( const graphene::chain::transaction& tx,
fc::flat_set<graphene::chain::account_id_type>& result,
bool ignore_custom_operation_required_auths );

} } // graphene::app
10 changes: 5 additions & 5 deletions libraries/chain/include/graphene/chain/protocol/operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ namespace graphene { namespace chain {
*
* @return a set of required authorities for @ref op
*/
void operation_get_required_authorities(const operation& op,
flat_set<account_id_type>& active,
flat_set<account_id_type>& owner,
vector<authority>& other,
bool ignore_custom_operation_required_auths);
void operation_get_required_authorities( const operation& op,
flat_set<account_id_type>& active,
flat_set<account_id_type>& owner,
vector<authority>& other,
bool ignore_custom_operation_required_auths );

void operation_validate( const operation& op );

Expand Down
69 changes: 36 additions & 33 deletions libraries/chain/include/graphene/chain/protocol/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ namespace graphene { namespace chain {
return results;
}

void get_required_authorities(flat_set<account_id_type>& active,
flat_set<account_id_type>& owner,
vector<authority>& other,
bool ignore_custom_operation_required_auths)const;
void get_required_authorities( flat_set<account_id_type>& active,
flat_set<account_id_type>& owner,
vector<authority>& other,
bool ignore_custom_operation_required_auths )const;

virtual uint64_t get_packed_size()const;

Expand Down Expand Up @@ -146,13 +146,14 @@ namespace graphene { namespace chain {
* signatures, but any non-minimal result will still pass
* validation.
*/
set<public_key_type> get_required_signatures(const chain_id_type& chain_id,
const flat_set<public_key_type>& available_keys,
const std::function<const authority*(account_id_type)>& get_active,
const std::function<const authority*(account_id_type)>& get_owner,
bool allow_non_immediate_owner,
bool ignore_custom_operation_required_authorities,
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH)const;
set<public_key_type> get_required_signatures(
const chain_id_type& chain_id,
const flat_set<public_key_type>& available_keys,
const std::function<const authority*(account_id_type)>& get_active,
const std::function<const authority*(account_id_type)>& get_owner,
bool allow_non_immediate_owner,
bool ignore_custom_operation_required_authorities,
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH )const;

/**
* Checks whether signatures in this signed transaction are sufficient to authorize the transaction.
Expand All @@ -168,26 +169,28 @@ namespace graphene { namespace chain {
* @param max_recursion maximum level of recursion when verifying, since an account
* can have another account in active authorities and/or owner authorities
*/
void verify_authority(const chain_id_type& chain_id,
const std::function<const authority*(account_id_type)>& get_active,
const std::function<const authority*(account_id_type)>& get_owner,
bool allow_non_immediate_owner,
bool ignore_custom_operation_required_auths,
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH)const;
void verify_authority(
const chain_id_type& chain_id,
const std::function<const authority*(account_id_type)>& get_active,
const std::function<const authority*(account_id_type)>& get_owner,
bool allow_non_immediate_owner,
bool ignore_custom_operation_required_auths,
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH )const;

/**
* This is a slower replacement for get_required_signatures()
* which returns a minimal set in all cases, including
* some cases where get_required_signatures() returns a
* non-minimal set.
*/
set<public_key_type> minimize_required_signatures(const chain_id_type& chain_id,
const flat_set<public_key_type>& available_keys,
const std::function<const authority*(account_id_type)>& get_active,
const std::function<const authority*(account_id_type)>& get_owner,
bool allow_non_immediate_owner,
bool ignore_custom_operation_required_auths,
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH) const;
set<public_key_type> minimize_required_signatures(
const chain_id_type& chain_id,
const flat_set<public_key_type>& available_keys,
const std::function<const authority*(account_id_type)>& get_active,
const std::function<const authority*(account_id_type)>& get_owner,
bool allow_non_immediate_owner,
bool ignore_custom_operation_required_auths,
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH) const;

/**
* @brief Extract public keys from signatures with given chain ID.
Expand Down Expand Up @@ -252,15 +255,15 @@ namespace graphene { namespace chain {
* @param active_approvals accounts that approved the operations with their active authories
* @param owner_approvals accounts that approved the operations with their owner authories
*/
void verify_authority(const vector<operation>& ops, const flat_set<public_key_type>& sigs,
const std::function<const authority*(account_id_type)>& get_active,
const std::function<const authority*(account_id_type)>& get_owner,
bool allow_non_immediate_owner,
bool ignore_custom_operation_required_auths,
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH,
bool allow_committee = false,
const flat_set<account_id_type>& active_aprovals = flat_set<account_id_type>(),
const flat_set<account_id_type>& owner_approvals = flat_set<account_id_type>());
void verify_authority( const vector<operation>& ops, const flat_set<public_key_type>& sigs,
const std::function<const authority*(account_id_type)>& get_active,
const std::function<const authority*(account_id_type)>& get_owner,
bool allow_non_immediate_owner,
bool ignore_custom_operation_required_auths,
uint32_t max_recursion = GRAPHENE_MAX_SIG_CHECK_DEPTH,
bool allow_committee = false,
const flat_set<account_id_type>& active_aprovals = flat_set<account_id_type>(),
const flat_set<account_id_type>& owner_approvals = flat_set<account_id_type>() );

/**
* @brief captures the result of evaluating the operations contained in the transaction
Expand Down
Loading

0 comments on commit b78ccaf

Please sign in to comment.