Resolve #207 Add API to get required fees.

This commit is contained in:
Daniel Larimer 2015-07-27 17:50:02 -04:00
parent bd4ab4f168
commit 86564e2a1b
2 changed files with 17 additions and 0 deletions

View file

@ -1120,4 +1120,14 @@ namespace graphene { namespace app {
return result;
}
vector<asset> database_api::get_required_fees( const vector<operation>& ops, asset_id_type id )const
{
vector<asset> result;
result.reserve(ops.size());
const asset_object& a = id(_db);
for( const auto& op : ops )
result.push_back( _db.current_fee_schedule().calculate_fee( op, a.options.core_exchange_rate ) );
return result;
}
} } // graphene::app

View file

@ -328,6 +328,12 @@ namespace graphene { namespace app {
vector<blinded_balance_object> get_blinded_balances( const flat_set<commitment_type>& commitments )const;
/**
* For each operation calculate the required fee in the specified asset type. If the asset type does
* not have a valid core_exchange_rate
*/
vector<asset> get_required_fees( const vector<operation>& ops, asset_id_type id = asset_id_type() )const;
private:
/** called every time a block is applied to report the objects that were changed */
void on_objects_changed(const vector<object_id_type>& ids);
@ -541,6 +547,7 @@ FC_API(graphene::app::database_api,
(get_required_signatures)
(verify_authority)
(get_blinded_balances)
(get_required_fees)
)
FC_API(graphene::app::history_api,
(get_account_history)