Skip to content

Commit

Permalink
Refactor pow2 required authorities to use visitor steemit#726
Browse files Browse the repository at this point in the history
  • Loading branch information
theoreticalbts committed Dec 20, 2016
1 parent e70b156 commit 52ac1f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
18 changes: 1 addition & 17 deletions libraries/protocol/include/steemit/protocol/steem_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,23 +614,7 @@ namespace steemit { namespace protocol {

void validate()const;

void get_required_active_authorities( flat_set<account_name_type>& a )const
{
if( !new_owner_key )
{
switch( work.which() )
{
case pow2_work::tag< pow2 >::value:
a.insert( work.get< pow2 >().input.worker_account );
break;
case pow2_work::tag< equihash_pow >::value:
a.insert( work.get< equihash_pow >().input.worker_account );
break;
default:
break;
}
}
}
void get_required_active_authorities( flat_set<account_name_type>& a )const;

void get_required_authorities( vector< authority >& a )const
{
Expand Down
25 changes: 25 additions & 0 deletions libraries/protocol/steem_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,31 @@ namespace steemit { namespace protocol {
work.visit( pow2_operation_validate_visitor() );
}

struct pow2_operation_get_required_active_visitor
{
typedef void result_type;

pow2_operation_get_required_active_visitor( flat_set< account_name_type >& required_active )
: _required_active( required_active ) {}

template< typename PowType >
void operator()( const PowType& work )const
{
_required_active.insert( work.input.worker_account );
}

flat_set<account_name_type>& _required_active;
};

void pow2_operation::get_required_active_authorities( flat_set<account_name_type>& a )const
{
if( !new_owner_key )
{
pow2_operation_get_required_active_visitor vtor( a );
work.visit( vtor );
}
}

void pow::create( const fc::ecc::private_key& w, const digest_type& i )
{
input = i;
Expand Down

0 comments on commit 52ac1f0

Please sign in to comment.