Merge branch 'master' of github.com:cryptonomex/graphene

This commit is contained in:
Daniel Larimer 2015-07-30 16:45:18 -04:00
commit 39c99fd0a7
24 changed files with 289 additions and 169 deletions

View file

@ -3,6 +3,7 @@ file(GLOB HEADERS "include/graphene/app/*.hpp")
add_library( graphene_app
api.cpp
application.cpp
impacted.cpp
plugin.cpp
)

View file

@ -20,6 +20,7 @@
#include <graphene/app/api.hpp>
#include <graphene/app/api_access.hpp>
#include <graphene/app/application.hpp>
#include <graphene/app/impacted.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/utilities/key_conversion.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
@ -659,7 +660,7 @@ namespace graphene { namespace app {
const auto& aobj = dynamic_cast<const proposal_object*>(obj);
assert( aobj != nullptr );
flat_set<account_id_type> impacted;
aobj->proposed_transaction.get_impacted_accounts( impacted );
transaction_get_impacted_accounts( aobj->proposed_transaction, impacted );
result.reserve( impacted.size() );
for( auto& item : impacted ) result.emplace_back(item);
break;
@ -717,7 +718,7 @@ namespace graphene { namespace app {
const auto& aobj = dynamic_cast<const transaction_object*>(obj);
assert( aobj != nullptr );
flat_set<account_id_type> impacted;
aobj->trx.get_impacted_accounts( impacted );
transaction_get_impacted_accounts( aobj->trx, impacted );
result.reserve( impacted.size() );
for( auto& item : impacted ) result.emplace_back(item);
break;

185
libraries/app/impacted.cpp Normal file
View file

@ -0,0 +1,185 @@
/*
* Copyright (c) 2015, Cryptonomex, Inc.
* All rights reserved.
*
* This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and
* the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification,
* are permitted until September 8, 2015, provided that the following conditions are met:
*
* 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <graphene/chain/protocol/authority.hpp>
#include <graphene/app/impacted.hpp>
namespace graphene { namespace app {
using namespace fc;
using namespace graphene::chain;
// TODO: Review all of these, especially no-ops
struct get_impacted_account_visitor
{
flat_set<account_id_type>& _impacted;
get_impacted_account_visitor( flat_set<account_id_type>& impact ):_impacted(impact) {}
typedef void result_type;
void operator()( const transfer_operation& op )
{
_impacted.insert( op.to );
}
void operator()( const limit_order_create_operation& op ) {}
void operator()( const limit_order_cancel_operation& op ) {}
void operator()( const call_order_update_operation& op ) {}
void operator()( const fill_order_operation& op )
{
_impacted.insert( op.account_id );
}
void operator()( const account_create_operation& op )
{
_impacted.insert( op.registrar );
_impacted.insert( op.referrer );
add_authority_accounts( _impacted, op.owner );
add_authority_accounts( _impacted, op.active );
}
void operator()( const account_update_operation& op )
{
_impacted.insert( op.account );
if( op.owner )
add_authority_accounts( _impacted, *(op.owner) );
if( op.active )
add_authority_accounts( _impacted, *(op.active) );
}
void operator()( const account_whitelist_operation& op )
{
_impacted.insert( op.account_to_list );
}
void operator()( const account_upgrade_operation& op ) {}
void operator()( const account_transfer_operation& op )
{
_impacted.insert( op.new_owner );
}
void operator()( const asset_create_operation& op ) {}
void operator()( const asset_update_operation& op )
{
if( op.new_issuer )
_impacted.insert( *(op.new_issuer) );
}
void operator()( const asset_update_bitasset_operation& op ) {}
void operator()( const asset_update_feed_producers_operation& op ) {}
void operator()( const asset_issue_operation& op )
{
_impacted.insert( op.issue_to_account );
}
void operator()( const asset_reserve_operation& op ) {}
void operator()( const asset_fund_fee_pool_operation& op ) {}
void operator()( const asset_settle_operation& op ) {}
void operator()( const asset_global_settle_operation& op ) {}
void operator()( const asset_publish_feed_operation& op ) {}
void operator()( const witness_create_operation& op ) {}
void operator()( const proposal_create_operation& op )
{
vector<authority> other;
for( const auto& proposed_op : op.proposed_ops )
operation_get_required_authorities( proposed_op.op, _impacted, _impacted, other );
for( auto& o : other )
add_authority_accounts( _impacted, o );
}
void operator()( const proposal_update_operation& op ) {}
void operator()( const proposal_delete_operation& op ) {}
void operator()( const withdraw_permission_create_operation& op )
{
_impacted.insert( op.authorized_account );
}
void operator()( const withdraw_permission_update_operation& op )
{
_impacted.insert( op.authorized_account );
}
void operator()( const withdraw_permission_claim_operation& op )
{
_impacted.insert( op.withdraw_from_account );
}
void operator()( const withdraw_permission_delete_operation& op )
{
_impacted.insert( op.authorized_account );
}
void operator()( const committee_member_create_operation& op ) {}
void operator()( const committee_member_update_global_parameters_operation& op ) {}
void operator()( const vesting_balance_create_operation& op )
{
_impacted.insert( op.owner );
}
void operator()( const vesting_balance_withdraw_operation& op ) {}
void operator()( const worker_create_operation& op ) {}
void operator()( const custom_operation& op ) {}
void operator()( const assert_operation& op ) {}
void operator()( const balance_claim_operation& op ) {}
void operator()( const override_transfer_operation& op )
{
_impacted.insert( op.to );
_impacted.insert( op.from );
_impacted.insert( op.issuer );
}
void operator()( const transfer_to_blind_operation& op )
{
_impacted.insert( op.from );
for( const auto& out : op.outputs )
add_authority_accounts( _impacted, out.owner );
}
void operator()( const blind_transfer_operation& op )
{
for( const auto& in : op.inputs )
add_authority_accounts( _impacted, in.owner );
for( const auto& out : op.outputs )
add_authority_accounts( _impacted, out.owner );
}
void operator()( const transfer_from_blind_operation& op )
{
_impacted.insert( op.to );
for( const auto& in : op.inputs )
add_authority_accounts( _impacted, in.owner );
}
};
void operation_get_impacted_accounts( const operation& op, flat_set<account_id_type>& result )
{
get_impacted_account_visitor vtor = get_impacted_account_visitor( result );
op.visit( vtor );
}
void transaction_get_impacted_accounts( const transaction& tx, flat_set<account_id_type>& result )
{
for( const auto& op : tx.operations )
operation_get_impacted_accounts( op, result );
}
} }

View file

@ -0,0 +1,36 @@
/*
* Copyright (c) 2015, Cryptonomex, Inc.
* All rights reserved.
*
* This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and
* the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification,
* are permitted until September 8, 2015, provided that the following conditions are met:
*
* 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <fc/container/flat.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/transaction.hpp>
#include <graphene/chain/protocol/types.hpp>
namespace graphene { namespace app {
void operation_get_impacted_accounts(
const graphene::chain::operation& op,
fc::flat_set<graphene::chain::account_id_type>& result );
void transaction_get_impacted_accounts(
const graphene::chain::transaction& tx,
fc::flat_set<graphene::chain::account_id_type>& result
);
} } // graphene::app

View file

@ -19,6 +19,7 @@ add_library( graphene_chain
protocol/types.cpp
protocol/address.cpp
protocol/authority.cpp
protocol/asset.cpp
protocol/assert.cpp
protocol/account.cpp

View file

@ -63,14 +63,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return registrar; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& )const;
void get_impacted_accounts( flat_set<account_id_type>& i )const
{
i.insert(registrar);
i.insert(referrer);
add_authority_accounts( i, owner );
add_authority_accounts( i, active );
}
};
/**
@ -109,16 +101,8 @@ namespace graphene { namespace chain {
void get_required_active_authorities( flat_set<account_id_type>& a )const
{ if( !owner ) a.insert( account ); }
void get_impacted_accounts( flat_set<account_id_type>& i )const
{
i.insert(account);
if( owner ) add_authority_accounts( i, *owner );
if( active ) add_authority_accounts( i, *active );
}
};
/**
* @brief This operation is used to whitelist and blacklist accounts, primarily for transacting in whitelisted assets
* @ingroup operations
@ -161,13 +145,8 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return authorizing_account; }
void validate()const { FC_ASSERT( fee.amount >= 0 ); FC_ASSERT(new_listing < 0x4); }
void get_impacted_accounts( flat_set<account_id_type>& i )const
{ i.insert(account_to_list); }
};
/**
* @brief Manage an account's membership status
* @ingroup operations
@ -224,15 +203,10 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return account_id; }
void validate()const;
void get_impacted_accounts( flat_set<account_id_type>& i )const
{
i.insert(new_owner);
}
};
} }
} } // graphene::chain
FC_REFLECT(graphene::chain::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)(extensions))
FC_REFLECT_TYPENAME( graphene::chain::account_whitelist_operation::account_listing)
FC_REFLECT_ENUM( graphene::chain::account_whitelist_operation::account_listing,

View file

@ -242,8 +242,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return issuer; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& k)const;
void get_impacted_accounts( flat_set<account_id_type>& i)const
{ if( new_issuer ) i.insert( *new_issuer ); }
};
/**
@ -358,8 +356,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return issuer; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& k)const;
void get_impacted_accounts( flat_set<account_id_type>& i)const
{ i.insert( issue_to_account ); }
};
/**
@ -381,8 +377,8 @@ namespace graphene { namespace chain {
void validate()const;
};
} } // graphene::chain
FC_REFLECT( graphene::chain::asset_options,
(max_supply)
(market_fee_percent)

View file

@ -101,6 +101,14 @@ namespace graphene { namespace chain {
flat_map<address,weight_type> address_auths;
};
/**
* Add all account members of the given authority to the given flat_set.
*/
void add_authority_accounts(
flat_set<account_id_type>& result,
const authority& a
);
} } // namespace graphene::chain
FC_REFLECT( graphene::chain::authority, (weight_threshold)(account_auths)(key_auths)(address_auths) )

View file

@ -29,7 +29,7 @@ namespace graphene { namespace chain {
}
};
}} // graphene::chain
} } // graphene::chain
FC_REFLECT( graphene::chain::balance_claim_operation::fee_parameters_type, )
FC_REFLECT( graphene::chain::balance_claim_operation,

View file

@ -1,9 +1,9 @@
#pragma once
#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/protocol/asset.hpp>
#include <graphene/chain/protocol/authority.hpp>
namespace graphene { namespace chain {
/**
@ -70,15 +70,9 @@ namespace graphene { namespace chain {
void get_required_authorities( vector<authority>& )const{}
void get_required_active_authorities( flat_set<account_id_type>& )const{}
void get_required_owner_authorities( flat_set<account_id_type>& )const{}
void get_impacted_accounts( flat_set<account_id_type>& )const{}
void validate()const{}
static uint64_t calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte );
static void add_authority_accounts( flat_set<account_id_type>& i, const authority& a )
{
for( auto& item : a.account_auths )
i.insert( item.first );
}
};
/**
@ -100,6 +94,7 @@ namespace graphene { namespace chain {
///@}
} }
} } // graphene::chain
FC_REFLECT_TYPENAME( graphene::chain::operation_result )
FC_REFLECT( graphene::chain::void_result, )

View file

@ -143,13 +143,6 @@ struct transfer_to_blind_operation : public base_operation
account_id_type fee_payer()const { return from; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& )const;
void get_impacted_accounts( flat_set<account_id_type>& i )const
{
i.insert(from);
for( const auto& out : outputs )
add_authority_accounts( i, out.owner );
}
};
/**
@ -171,12 +164,6 @@ struct transfer_from_blind_operation : public base_operation
account_id_type fee_payer()const { return GRAPHENE_TEMP_ACCOUNT; }
void validate()const;
void get_impacted_accounts( flat_set<account_id_type>& i )const
{
i.insert(to);
for( const auto& in : inputs )
add_authority_accounts( i, in.owner );
}
void get_required_authorities( vector<authority>& a )const
{
for( const auto& in : inputs )
@ -243,13 +230,6 @@ struct blind_transfer_operation : public base_operation
void validate()const;
share_type calculate_fee( const fee_parameters_type& k )const;
void get_impacted_accounts( flat_set<account_id_type>& i )const
{
for( const auto& in : inputs )
add_authority_accounts( i, in.owner );
for( const auto& out : outputs )
add_authority_accounts( i, out.owner );
}
void get_required_authorities( vector<authority>& a )const
{
for( const auto& in : inputs )
@ -258,6 +238,7 @@ struct blind_transfer_operation : public base_operation
};
///@} endgroup stealth
} } // graphene::chain
FC_REFLECT( graphene::chain::stealth_confirmation,
@ -281,4 +262,3 @@ FC_REFLECT( graphene::chain::blind_transfer_operation,
FC_REFLECT( graphene::chain::transfer_to_blind_operation::fee_parameters_type, (fee)(price_per_output) )
FC_REFLECT( graphene::chain::transfer_from_blind_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::blind_transfer_operation::fee_parameters_type, (fee)(price_per_output) )

View file

@ -29,7 +29,7 @@ namespace graphene { namespace chain {
share_type calculate_fee(const fee_parameters_type& k)const;
};
} } // namespace graphene::chain
FC_REFLECT( graphene::chain::custom_operation::fee_parameters_type, (fee)(price_per_kbyte) )
FC_REFLECT( graphene::chain::custom_operation, (fee)(payer)(required_auths)(id)(data) )

View file

@ -133,8 +133,6 @@ namespace graphene { namespace chain {
/// This is a virtual operation; there is no fee
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
void get_impacted_accounts( flat_set<account_id_type>& i)const
{ i.insert( account_id ); }
};
} } // graphene::chain

View file

@ -79,25 +79,8 @@ namespace graphene { namespace chain {
flat_set<account_id_type>& owner,
vector<authority>& other );
void operation_get_impacted_accounts( const operation& op,
flat_set<account_id_type>& accounts );
void operation_validate( const operation& op );
/**
* Used to track the result of applying an operation and when it was applied.
*
* TODO: this doesn't belong here.
*/
struct applied_operation
{
operation op;
operation_result result;
uint32_t block_num;
uint16_t transaction_num;
uint16_t op_num;
};
/**
* @brief necessary to support nested operations inside the proposal_create_operation
*/

View file

@ -64,8 +64,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return fee_paying_account; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& k)const;
void get_impacted_accounts( flat_set<account_id_type>& )const;
};
/**

View file

@ -104,7 +104,6 @@ namespace graphene { namespace chain {
}
void get_required_authorities( flat_set<account_id_type>& active, flat_set<account_id_type>& owner, vector<authority>& other )const;
void get_impacted_accounts( flat_set<account_id_type>& )const;
};
/**
@ -194,8 +193,7 @@ namespace graphene { namespace chain {
/// @} transactions group
} }
} } // graphene::chain
FC_REFLECT( graphene::chain::transaction, (ref_block_num)(ref_block_prefix)(expiration)(operations)(extensions) )
FC_REFLECT_DERIVED( graphene::chain::signed_transaction, (graphene::chain::transaction), (signatures) )

View file

@ -40,8 +40,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return from; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& k)const;
void get_impacted_accounts( flat_set<account_id_type>& i )const
{ i.insert(to); }
};
/**
@ -75,12 +73,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return issuer; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& k)const;
void get_impacted_accounts( flat_set<account_id_type>& i )const
{
i.insert(to);
i.insert(from);
i.insert(issuer);
}
};
}} // graphene::chain

View file

@ -56,9 +56,6 @@ namespace graphene { namespace chain {
FC_ASSERT( fee.amount >= 0 );
FC_ASSERT( amount.amount > 0 );
}
void get_impacted_accounts( flat_set<account_id_type>& i )const
{ i.insert(owner); }
};
/**
@ -87,7 +84,8 @@ namespace graphene { namespace chain {
}
};
}} // graphene::chain
} } // graphene::chain
FC_REFLECT( graphene::chain::vesting_balance_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type, (fee) )

View file

@ -43,9 +43,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return withdraw_from_account; }
void validate()const;
void get_impacted_accounts( flat_set<account_id_type>& i)const
{ i.insert( authorized_account ); }
};
/**
@ -81,8 +78,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return withdraw_from_account; }
void validate()const;
void get_impacted_accounts( flat_set<account_id_type>& i)const
{ i.insert( authorized_account ); }
};
/**
@ -121,8 +116,6 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return withdraw_to_account; }
void validate()const;
share_type calculate_fee(const fee_parameters_type& k)const;
void get_impacted_accounts( flat_set<account_id_type>& i)const
{ i.insert( withdraw_from_account ); }
};
/**
@ -147,11 +140,10 @@ namespace graphene { namespace chain {
account_id_type fee_payer()const { return withdraw_from_account; }
void validate()const;
void get_impacted_accounts( flat_set<account_id_type>& i)const
{ i.insert( authorized_account ); }
};
} } // graphene::chain
FC_REFLECT( graphene::chain::withdraw_permission_create_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::withdraw_permission_update_operation::fee_parameters_type, (fee) )
FC_REFLECT( graphene::chain::withdraw_permission_claim_operation::fee_parameters_type, (fee)(price_per_kbyte) )
@ -164,4 +156,3 @@ FC_REFLECT( graphene::chain::withdraw_permission_update_operation, (fee)(withdra
FC_REFLECT( graphene::chain::withdraw_permission_claim_operation, (fee)(withdraw_permission)(withdraw_from_account)(withdraw_to_account)(amount_to_withdraw)(memo) );
FC_REFLECT( graphene::chain::withdraw_permission_delete_operation, (fee)(withdraw_from_account)(authorized_account)
(withdrawal_permission) )

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2015, Cryptonomex, Inc.
* All rights reserved.
*
* This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and
* the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification,
* are permitted until September 8, 2015, provided that the following conditions are met:
*
* 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <graphene/chain/protocol/authority.hpp>
namespace graphene { namespace chain {
void add_authority_accounts(
flat_set<account_id_type>& result,
const authority& a
)
{
for( auto& item : a.account_auths )
result.insert( item.first );
}
} } // graphene::chain

View file

@ -50,24 +50,6 @@ struct required_auth_visitor
}
};
struct get_impacted_account_visitor
{
flat_set<account_id_type>& _impacted;
get_impacted_account_visitor( flat_set<account_id_type>& impact ):_impacted(impact) {}
typedef void result_type;
template<typename T>
void operator()( const T& o )const
{
o.get_impacted_accounts( _impacted );
}
};
void operation_get_impacted_accounts( const operation& op, flat_set<account_id_type>& result )
{
op.visit( get_impacted_account_visitor( result ) );
}
void operation_get_required_authorities( const operation& op, vector<authority>& result )
{
op.visit( required_auth_visitor( result ) );

View file

@ -56,14 +56,6 @@ share_type proposal_update_operation::calculate_fee(const fee_parameters_type& k
{
return k.fee + calculate_data_fee( fc::raw::pack_size(*this), k.price_per_kbyte );
}
void proposal_create_operation::get_impacted_accounts( flat_set<account_id_type>& i )const
{
vector<authority> other;
for( const auto& op : proposed_ops )
operation_get_required_authorities( op.op, i, i, other );
for( auto& o : other )
add_authority_accounts( i, o );
}
void proposal_update_operation::get_required_authorities( vector<authority>& o )const
{
@ -76,14 +68,17 @@ void proposal_update_operation::get_required_authorities( vector<authority>& o )
o.emplace_back( std::move(auth) );
}
void proposal_update_operation::get_required_active_authorities( flat_set<account_id_type>& a )const
{
for( const auto& i : active_approvals_to_add ) a.insert(i);
for( const auto& i : active_approvals_to_remove ) a.insert(i);
}
void proposal_update_operation::get_required_owner_authorities( flat_set<account_id_type>& a )const
{
for( const auto& i : owner_approvals_to_add ) a.insert(i);
for( const auto& i : owner_approvals_to_remove ) a.insert(i);
}
} } // graphene::chain

View file

@ -316,10 +316,4 @@ void signed_transaction::verify_authority( const std::function<const authority*(
graphene::chain::verify_authority( operations, get_signature_keys(), get_active, get_owner, max_recursion );
} FC_CAPTURE_AND_RETHROW( (*this) ) }
void transaction::get_impacted_accounts( flat_set<account_id_type>& impacted ) const
{
for( const auto& op : operations )
operation_get_impacted_accounts( op, impacted );
}
} } // graphene::chain

View file

@ -18,6 +18,8 @@
#include <graphene/account_history/account_history_plugin.hpp>
#include <graphene/app/impacted.hpp>
#include <graphene/chain/account_evaluator.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/config.hpp>
@ -58,35 +60,11 @@ class account_history_plugin_impl
flat_set<account_id_type> _tracked_accounts;
};
struct operation_get_impacted_accounts
{
const operation_history_object& _op_history;
const account_history_plugin& _plugin;
flat_set<account_id_type>& _impacted;
operation_get_impacted_accounts( const operation_history_object& oho, const account_history_plugin& ahp, flat_set<account_id_type>& impact )
:_op_history(oho),_plugin(ahp),_impacted(impact)
{}
typedef void result_type;
void operator()( const account_create_operation& o )const {
_impacted.insert( _op_history.result.get<object_id_type>() );
}
template<typename T>
void operator()( const T& o )const
{
o.get_impacted_accounts( _impacted );
}
};
account_history_plugin_impl::~account_history_plugin_impl()
{
return;
}
void account_history_plugin_impl::update_account_histories( const signed_block& b )
{
graphene::chain::database& db = database();
@ -102,7 +80,11 @@ void account_history_plugin_impl::update_account_histories( const signed_block&
flat_set<account_id_type> impacted;
vector<authority> other;
operation_get_required_authorities( op.op, impacted, impacted, other );
op.op.visit( operation_get_impacted_accounts( oho, _self, impacted ) );
if( op.op.which() == operation::tag< account_create_operation >::value )
impacted.insert( oho.result.get<object_id_type>() );
else
graphene::app::operation_get_impacted_accounts( op.op, impacted );
for( auto& a : other )
for( auto& item : a.account_auths )