From 90e04d029048956a5d716f4c9cb74eb074f8ed69 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Tue, 7 Jul 2015 18:46:27 -0400 Subject: [PATCH] Refactoring fee schedule to make things more flex - this code does not compile, there are now circular references that need to be resolved. --- libraries/chain/fee_schedule.cpp | 65 +++ .../include/graphene/chain/account_object.hpp | 27 +- .../chain/include/graphene/chain/block.hpp | 2 +- .../graphene/chain/chain_parameters.hpp | 119 ++++ .../include/graphene/chain/fee_schedule.hpp | 52 ++ .../graphene/chain/global_property_object.hpp | 1 + .../include/graphene/chain/operations.hpp | 549 +++++++++--------- .../chain/include/graphene/chain/types.hpp | 256 +------- libraries/chain/types.cpp | 29 - 9 files changed, 518 insertions(+), 582 deletions(-) create mode 100644 libraries/chain/fee_schedule.cpp create mode 100644 libraries/chain/include/graphene/chain/chain_parameters.hpp create mode 100644 libraries/chain/include/graphene/chain/fee_schedule.hpp diff --git a/libraries/chain/fee_schedule.cpp b/libraries/chain/fee_schedule.cpp new file mode 100644 index 00000000..fe47a764 --- /dev/null +++ b/libraries/chain/fee_schedule.cpp @@ -0,0 +1,65 @@ +#include + +namespace graphene { namespace chain { + + fee_schedule::fee_schedule() + { + } + + fee_schedule fee_schedule::get_default() + { + fee_schedule result; + for( uint32_t i = 0; i < fee_parameters.count(); ++i ) + { + fee_parameters x; x.set_which(i); + result.parameters.insert(x); + } + return result; + } + + struct fee_schedule_validate_visitor + { + typedef result_type void; + + template + void operator()( const T& p )const + { + p.validate(); + } + }; + + void fee_schedule::validate()const + { + for( const auto& f : parameters ) + f.visit( fee_schedule_validate_visitor() ); + } + + struct calc_fee_visitor + { + typedef result_type asset; + + const fee_parameters& param; + calc_fee_visitor( const fee_parameters& p ):param(p){} + + template + asset operator()( const OpType& op )const + { + return op.calculate_fee( param.get() ); + } + }; + + asset fee_schedule::calculate_fee( const operation& op, const price& core_exchange_rate )const + { + fee_parameters params; params.set_which(op.which()); + auto itr = parameters.find(params); + if( itr != parameters.end() ) params = *itr; + share_type base_value op.visit( calc_fee_visitor( params ) ); + auto scaled = fc::uint128(base_value.value) * scale_factor; + scaled /= GRAPHENE_100_PERCENT; + FC_ASSERT( scaled <= GRAPHENE_MAX_SHARE_SUPPLY ); + auto result = asset( scaled.to_uint64(), 0 ) * core_exchange_rate; + FC_ASSERT( result.amount <= GRAPHENE_MAX_SHARE_SUPPLY ); + return result; + } + +} } // graphene::chain diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 0e313160..75c5c826 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace graphene { namespace chain { class database; @@ -156,28 +157,8 @@ class database; /// operations the account may perform. authority active; - /// These are the fields which can be updated by the active authority. - struct options_type { - /// The memo key is the key this account will typically use to encrypt/sign transaction memos and other non- - /// validated account activities. This field is here to prevent confusion if the active authority has zero or - /// multiple keys in it. - public_key_type memo_key; - /// If this field is set to an account ID other than 0, this account's votes will be ignored and its stake - /// will be counted as voting for the referenced account's selected votes instead. - account_id_type voting_account; - - /// The number of active witnesses this account votes the blockchain should appoint - /// Must not exceed the actual number of witnesses voted for in @ref votes - uint16_t num_witness = 0; - /// The number of active committee members this account votes the blockchain should appoint - /// Must not exceed the actual number of committee members voted for in @ref votes - uint16_t num_committee = 0; - /// This is the list of vote IDs this account votes for. The weight of these votes is determined by this - /// account's balance of core asset. - flat_set votes; - - void validate()const; - } options; + typedef account_options options_type; + account_options options; /// The reference implementation records the account's statistics in a separate object. This field contains the /// ID of that object. @@ -349,8 +330,6 @@ FC_REFLECT_DERIVED( graphene::chain::account_object, (name)(owner)(active)(options)(statistics)(whitelisting_accounts)(blacklisting_accounts) (cashback_vb) ) -FC_REFLECT(graphene::chain::account_object::options_type, (memo_key)(voting_account)(num_witness)(num_committee)(votes)) - FC_REFLECT_DERIVED( graphene::chain::account_balance_object, (graphene::db::object), (owner)(asset_type)(balance) ) diff --git a/libraries/chain/include/graphene/chain/block.hpp b/libraries/chain/include/graphene/chain/block.hpp index 5f3e1357..5b5746d0 100644 --- a/libraries/chain/include/graphene/chain/block.hpp +++ b/libraries/chain/include/graphene/chain/block.hpp @@ -34,7 +34,7 @@ namespace graphene { namespace chain { secret_hash_type next_secret_hash; secret_hash_type previous_secret; checksum_type transaction_merkle_root; - vector extensions; + flat_set extensions; static uint32_t num_from_id(const block_id_type& id); }; diff --git a/libraries/chain/include/graphene/chain/chain_parameters.hpp b/libraries/chain/include/graphene/chain/chain_parameters.hpp new file mode 100644 index 00000000..4cf84fb3 --- /dev/null +++ b/libraries/chain/include/graphene/chain/chain_parameters.hpp @@ -0,0 +1,119 @@ +/* + * 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 + +namespace graphene { namespace chain { + + typedef static_variant<> parameter_extension; + struct chain_parameters + { + fee_schedule current_fees; ///< current schedule of fees + uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks + uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events + uint32_t genesis_proposal_review_period = GRAPHENE_DEFAULT_GENESIS_PROPOSAL_REVIEW_PERIOD_SEC; ///< minimum time in seconds that a proposed transaction requiring genesis authority may not be signed, prior to expiration + uint32_t maximum_transaction_size = GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE; ///< maximum allowable size in bytes for a transaction + uint32_t maximum_block_size = GRAPHENE_DEFAULT_MAX_BLOCK_SIZE; ///< maximum allowable size in bytes for a block + uint32_t maximum_undo_history = GRAPHENE_DEFAULT_MAX_UNDO_HISTORY; ///< maximum number of undo states to keep in RAM + uint32_t maximum_time_until_expiration = GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION; ///< maximum lifetime in seconds for transactions to be valid, before expiring + uint32_t maximum_proposal_lifetime = GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC; ///< maximum lifetime in seconds for proposed transactions to be kept, before expiring + uint8_t maximum_asset_whitelist_authorities = GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES; ///< maximum number of accounts which an asset may list as authorities for its whitelist OR blacklist + uint8_t maximum_asset_feed_publishers = GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS; ///< the maximum number of feed publishers for a given asset + uint16_t maximum_witness_count = GRAPHENE_DEFAULT_MAX_WITNESSES; ///< maximum number of active witnesses + uint16_t maximum_committee_count = GRAPHENE_DEFAULT_MAX_COMMITTEE; ///< maximum number of active delegates + uint16_t maximum_authority_membership = GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP; ///< largest number of keys/accounts an authority can have + uint16_t reserve_percent_of_fee = GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE; ///< the percentage of the network's allocation of a fee that is taken out of circulation + uint16_t network_percent_of_fee = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; ///< percent of transaction fees paid to network + uint16_t lifetime_referrer_percent_of_fee = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE; ///< percent of transaction fees paid to network + uint32_t cashback_vesting_period_seconds = GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC; ///< time after cashback rewards are accrued before they become liquid + share_type cashback_vesting_threshold = GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD; ///< the maximum cashback that can be received without vesting + uint16_t max_bulk_discount_percent_of_fee = GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT; ///< the maximum percentage discount for bulk discounts + share_type bulk_discount_threshold_min = GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN; ///< the minimum amount of fees paid to qualify for bulk discounts + share_type bulk_discount_threshold_max = GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX; ///< the amount of fees paid to qualify for the max bulk discount percent + bool count_non_member_votes = true; ///< set to false to restrict voting privlegages to member accounts + bool allow_non_member_whitelists = false; ///< true if non-member accounts may set whitelists and blacklists; false otherwise + share_type witness_pay_per_block = GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK; ///< CORE to be allocated to witnesses (per block) + share_type worker_budget_per_day = GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY; ///< CORE to be allocated to workers (per day) + uint16_t max_predicate_opcode = GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE; ///< predicate_opcode must be less than this number + share_type fee_liquidation_threshold = GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD; ///< value in CORE at which accumulated fees in blockchain-issued market assets should be liquidated + uint16_t accounts_per_fee_scale = GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE; ///< number of accounts between fee scalings + uint8_t account_fee_scale_bitshifts = GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS; ///< number of times to left bitshift account registration fee at each scaling + flat_set extensions; + + void validate()const + { + FC_ASSERT( reserve_percent_of_fee <= GRAPHENE_100_PERCENT ); + FC_ASSERT( network_percent_of_fee <= GRAPHENE_100_PERCENT ); + FC_ASSERT( max_bulk_discount_percent_of_fee <= GRAPHENE_100_PERCENT ); + FC_ASSERT( lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT ); + FC_ASSERT( network_percent_of_fee + lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT ); + FC_ASSERT( bulk_discount_threshold_min <= bulk_discount_threshold_max ); + FC_ASSERT( bulk_discount_threshold_min > 0 ); + + FC_ASSERT( block_interval <= GRAPHENE_MAX_BLOCK_INTERVAL ); + FC_ASSERT( block_interval > 0 ); + FC_ASSERT( maintenance_interval > block_interval, + "Maintenance interval must be longer than block interval" ); + FC_ASSERT( maintenance_interval % block_interval == 0, + "Maintenance interval must be a multiple of block interval" ); + FC_ASSERT( maximum_transaction_size >= GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT, + "Transaction size limit is too low" ); + FC_ASSERT( maximum_block_size >= GRAPHENE_MIN_BLOCK_SIZE_LIMIT, + "Block size limit is too low" ); + FC_ASSERT( maximum_time_until_expiration > block_interval, + "Maximum transaction expiration time must be greater than a block interval" ); + FC_ASSERT( maximum_proposal_lifetime - genesis_proposal_review_period > block_interval, + "Genesis proposal review period must be less than the maximum proposal lifetime" ); + } + }; + +} } // graphene::chain + +FC_REFLECT( graphene::chain::chain_parameters, + (current_fees) + (block_interval) + (maintenance_interval) + (genesis_proposal_review_period) + (maximum_transaction_size) + (maximum_block_size) + (maximum_undo_history) + (maximum_time_until_expiration) + (maximum_proposal_lifetime) + (maximum_asset_whitelist_authorities) + (maximum_asset_feed_publishers) + (maximum_witness_count) + (maximum_committee_count) + (maximum_authority_membership) + (reserve_percent_of_fee) + (network_percent_of_fee) + (lifetime_referrer_percent_of_fee) + (max_bulk_discount_percent_of_fee) + (cashback_vesting_period_seconds) + (cashback_vesting_threshold) + (bulk_discount_threshold_min) + (bulk_discount_threshold_max) + (count_non_member_votes) + (allow_non_member_whitelists) + (witness_pay_per_block) + (worker_budget_per_day) + (max_predicate_opcode) + (fee_liquidation_threshold) + (accounts_per_fee_scale) + (account_fee_scale_bitshifts) + (extensions) + ) diff --git a/libraries/chain/include/graphene/chain/fee_schedule.hpp b/libraries/chain/include/graphene/chain/fee_schedule.hpp new file mode 100644 index 00000000..401483e8 --- /dev/null +++ b/libraries/chain/include/graphene/chain/fee_schedule.hpp @@ -0,0 +1,52 @@ +#pragma once +#include + +namespace graphene { namespace chain { + + template struct transform_to_fee_parameters; + template + struct transform_to_fee_parameters> + { + typedef fc::static_variant< typename T::fee_parameters_type... > type; + }; + typedef transform_to_fee_parameters::type fee_parameters; + + /** + * @brief contains all of the parameters necessary to calculate the fee for any operation + */ + struct fee_schedule + { + fee_schedule(); + + static fee_schedule get_default(); + + /** + * Finds the appropriate fee parameter struct for the operation + * and then calculates the appropriate fee. + */ + asset calculate_fee( const operation& op, const price& core_exchange_rate = price::unit_price() )const; + void set_fee( operation& op, const price& core_exchange_rate = price::unit_price() )const; + + /** + * Validates all of the parameters are present and accounted for. + */ + void validate()const; + + /** + * @note must be sorted by fee_parameters.which() and have no duplicates + */ + flat_set parameters; + uint32_t scale; ///< fee * scale / GRAPHENE_100_PERCENT + }; + + typedef fee_schedule fee_schedule_type; + +} } // graphene::chain + +FC_REFLECT_TYPENAME( graphene::chain::fee_parameters ) +FC_REFLECT( graphene::chain::fee_schedule, (parameters) ) + + + + +} } diff --git a/libraries/chain/include/graphene/chain/global_property_object.hpp b/libraries/chain/include/graphene/chain/global_property_object.hpp index ee7e53c5..126458b0 100644 --- a/libraries/chain/include/graphene/chain/global_property_object.hpp +++ b/libraries/chain/include/graphene/chain/global_property_object.hpp @@ -16,6 +16,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once +#include #include #include #include diff --git a/libraries/chain/include/graphene/chain/operations.hpp b/libraries/chain/include/graphene/chain/operations.hpp index f5d0d6f5..8d2c6b6e 100644 --- a/libraries/chain/include/graphene/chain/operations.hpp +++ b/libraries/chain/include/graphene/chain/operations.hpp @@ -31,7 +31,6 @@ /// we should remove these headers #include #include -#include #include #include @@ -46,13 +45,13 @@ namespace graphene { namespace chain { struct void_result{}; typedef fc::static_variant operation_result; - struct balance_accumulator + struct base_operation { - void adjust( account_id_type account, const asset& delta ) + template + share_type calculate_fee(const T& params)const { - balance[ std::make_pair(account, delta.asset_id) ] += delta.amount; + return params.fee; } - flat_map< pair, share_type > balance; }; /** @@ -114,18 +113,19 @@ namespace graphene { namespace chain { * pre or post conditions for other operations. * */ - struct assert_operation + struct assert_operation : public base_operation { + struct fee_parameters_type { share_type fee = 150000; }; + asset fee; account_id_type fee_paying_account; + // TODO: replace this with a pure vector because all nodes need to know about all predicates and + // this will simplify the code. vector> predicates; flat_set required_auths; account_id_type fee_payer()const { return fee_paying_account; } - share_type calculate_fee(const fee_schedule_type& k)const; void validate()const; - - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } }; /** @@ -135,8 +135,10 @@ namespace graphene { namespace chain { * vesting balance, @ref total_claimed must not exceed @ref balance_object::available at the time of evaluation. If * the object contains a non-vesting balance, @ref total_claimed must be the full balance of the object. */ - struct balance_claim_operation + struct balance_claim_operation : public base_operation { + struct fee_parameters_type {}; + asset fee; account_id_type deposit_to_account; balance_id_type balance_to_claim; @@ -144,20 +146,46 @@ namespace graphene { namespace chain { asset total_claimed; account_id_type fee_payer()const { return deposit_to_account; } - share_type calculate_fee(const fee_schedule_type& k)const { return 0; } + share_type calculate_fee(const fee_parameters_type& )const { return 0; } void validate()const; + }; - void get_balance_delta(balance_accumulator& acc, const operation_result& = asset())const { - acc.adjust(deposit_to_account, total_claimed); - acc.adjust(fee_payer(), -fee); - } + + /// These are the fields which can be updated by the active authority. + struct account_options + { + /// The memo key is the key this account will typically use to encrypt/sign transaction memos and other non- + /// validated account activities. This field is here to prevent confusion if the active authority has zero or + /// multiple keys in it. + public_key_type memo_key; + /// If this field is set to an account ID other than 0, this account's votes will be ignored and its stake + /// will be counted as voting for the referenced account's selected votes instead. + account_id_type voting_account; + + /// The number of active witnesses this account votes the blockchain should appoint + /// Must not exceed the actual number of witnesses voted for in @ref votes + uint16_t num_witness = 0; + /// The number of active committee members this account votes the blockchain should appoint + /// Must not exceed the actual number of committee members voted for in @ref votes + uint16_t num_committee = 0; + /// This is the list of vote IDs this account votes for. The weight of these votes is determined by this + /// account's balance of core asset. + flat_set votes; + + void validate()const; }; /** * @ingroup operations */ - struct account_create_operation + struct account_create_operation : public base_operation { + struct fee_parameters_type { + uint64_t basic_fee = 5*GRAPHENE_BLOCKCHAIN_PRECISION; ///< the cost to register the cheapest non-free account + uint64_t premium_fee = 2000*GRAPHENE_BLOCKCHAIN_PRECISION; ///< the cost to register the cheapest non-free account + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; + }; + asset fee; /// This account pays the fee. Must be a lifetime member. account_id_type registrar; @@ -172,13 +200,11 @@ namespace graphene { namespace chain { authority owner; authority active; - account_object::options_type options; + account_options options; account_id_type fee_payer()const { return registrar; } - void validate()const; - share_type calculate_fee( const fee_schedule_type& k )const; - - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust( fee_payer(), -fee ); } + void validate()const; + share_type calculate_fee(const fee_parameters_type& )const; }; /** @@ -200,8 +226,9 @@ namespace graphene { namespace chain { * This operation requires authorizing_account's signature, but not account_to_list's. The fee is paid by * authorizing_account. */ - struct account_whitelist_operation + struct account_whitelist_operation : public base_operation { + struct fee_parameters_type { share_type fee = 300000; }; enum account_listing { no_listing = 0x0, ///< No opinion is specified about this account white_listed = 0x1, ///< This account is whitelisted, but not blacklisted @@ -221,9 +248,6 @@ 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); } - share_type calculate_fee(const fee_schedule_type& k)const { return k.account_whitelist_fee; } - - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust( fee_payer(), -fee ); } }; /** @@ -233,8 +257,13 @@ namespace graphene { namespace chain { * This operation is used to update an existing account. It can be used to update the authorities, or adjust the options on the account. * See @ref account_object::options_type for the options which may be updated. */ - struct account_update_operation + struct account_update_operation : public base_operation { + struct fee_parameters_type { + share_type fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; + }; + asset fee; /// The account to update account_id_type account; @@ -245,12 +274,11 @@ namespace graphene { namespace chain { optional active; /// New account options - optional new_options; + optional new_options; account_id_type fee_payer()const { return account; } void validate()const; - share_type calculate_fee( const fee_schedule_type& k )const; - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust( fee_payer(), -fee ); } + share_type calculate_fee( const fee_parameters_type& k )const; }; /** @@ -266,8 +294,13 @@ namespace graphene { namespace chain { * Any account may use this operation to become a lifetime member by setting @ref upgrade_to_lifetime_member to * true. Once an account has become a lifetime member, it may not use this operation anymore. */ - struct account_upgrade_operation + struct account_upgrade_operation : public base_operation { + struct fee_parameters_type { + uint64_t membership_annual_fee = 2000 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint64_t membership_lifetime_fee = 10000 * GRAPHENE_BLOCKCHAIN_PRECISION; ///< the cost to upgrade to a lifetime member + }; + asset fee; /// The account to upgrade; must not already be a lifetime member account_id_type account_to_upgrade; @@ -276,8 +309,7 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return account_to_upgrade; } void validate()const; - share_type calculate_fee( const fee_schedule_type& k )const; - void get_balance_delta( balance_accumulator& acc, const operation_result& = asset())const { acc.adjust( fee_payer(), -fee ); } + share_type calculate_fee( const fee_parameters_type& k )const; }; /** @@ -293,17 +325,17 @@ namespace graphene { namespace chain { * * This operation will clear the account's whitelist statuses, but not the blacklist statuses. */ - struct account_transfer_operation + struct account_transfer_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; account_id_type account_id; account_id_type new_owner; account_id_type fee_payer()const { return account_id; } void validate()const; - share_type calculate_fee( const fee_schedule_type& k )const; - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust( fee_payer(), -fee ); } }; /** @@ -313,17 +345,17 @@ namespace graphene { namespace chain { * Accounts which wish to become delegates may use this operation to create a delegate object which stakeholders may * vote on to approve its position as a delegate. */ - struct delegate_create_operation + struct delegate_create_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; /// The account which owns the delegate. This account pays the fee for this operation. account_id_type delegate_account; string url; account_id_type fee_payer()const { return delegate_account; } - void validate()const; - share_type calculate_fee( const fee_schedule_type& k )const; - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust( fee_payer(), -fee ); } + void validate()const; }; /** @@ -333,8 +365,10 @@ namespace graphene { namespace chain { * Accounts which wish to become witnesses may use this operation to create a witness object which stakeholders may * vote on to approve its position as a witness. */ - struct witness_create_operation + struct witness_create_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; /// The account which owns the delegate. This account pays the fee for this operation. account_id_type witness_account; @@ -343,18 +377,20 @@ namespace graphene { namespace chain { secret_hash_type initial_secret; account_id_type fee_payer()const { return witness_account; } - void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } + void validate()const; }; /** * @ingroup operations * Used to move witness pay from accumulated_income to their account balance. + * + * TODO: remove this operation, send witness pay into a vesting balance object and + * have the witness claim the funds from there. */ - struct witness_withdraw_pay_operation + struct witness_withdraw_pay_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; /// The account to pay. Must match from_witness->witness_account. This account pays the fee for this operation. account_id_type to_account; @@ -362,14 +398,7 @@ namespace graphene { namespace chain { share_type amount; account_id_type fee_payer()const { return to_account; } - void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust( fee_payer(), -fee ); - acc.adjust( to_account, amount ); - } + void validate()const; }; /** @@ -383,15 +412,15 @@ namespace graphene { namespace chain { * This operation may only be used in a proposed transaction, and a proposed transaction which contains this * operation must have a review period specified in the current global parameters before it may be accepted. */ - struct global_parameters_update_operation + struct global_parameters_update_operation : public base_operation { - asset fee; - chain_parameters new_parameters; + struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + + asset fee; + fc::fwd new_parameters; account_id_type fee_payer()const { return account_id_type(); } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust( fee_payer(), -fee ); } }; /** @@ -467,8 +496,13 @@ namespace graphene { namespace chain { * @post to account's balance will be increased by amount * @return n/a */ - struct transfer_operation + struct transfer_operation : public base_operation { + struct fee_parameters_type { + uint64_t base_fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = 10; /// only required for large memos. + }; + asset fee; /// Account to transfer asset from account_id_type from; @@ -481,14 +515,8 @@ namespace graphene { namespace chain { optional memo; account_id_type fee_payer()const { return from; } - void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust( fee_payer(), -fee ); - acc.adjust( from, -amount ); - acc.adjust( to, amount ); - } + void validate()const; + share_type calculate_fee(const fee_parameters_type& k)const; }; /** @@ -499,8 +527,13 @@ namespace graphene { namespace chain { * @pre amount.asset_id->issuer == issuer * @pre issuer != from because this is pointless, use a normal transfer operation */ - struct override_transfer_operation + struct override_transfer_operation : public base_operation { + struct fee_parameters_type { + uint64_t base_fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = 10; /// only required for large memos. + }; + asset fee; account_id_type issuer; /// Account to transfer asset from @@ -515,21 +548,22 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta( balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust( fee_payer(), -fee ); - acc.adjust( from, -amount ); - acc.adjust( to, amount ); - } + share_type calculate_fee(const fee_parameters_type& k)const; }; /** * @ingroup operations */ - struct asset_create_operation + struct asset_create_operation : public base_operation { + struct fee_parameters_type { + uint64_t symbol3 = 500000 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint64_t symbol4 = 300000 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint64_t long_symbol = 5000 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = 10; /// only required for large memos. + }; + asset fee; /// This account must sign and pay the fee for this operation. Later, this account may update the asset account_id_type issuer; @@ -552,8 +586,7 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; - share_type calculate_fee( const fee_schedule_type& k )const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } + share_type calculate_fee( const fee_parameters_type& k )const; }; /** @@ -566,8 +599,10 @@ namespace graphene { namespace chain { * used as backing for other bitassets, those bitassets will be force settled at their current * feed price. */ - struct asset_global_settle_operation + struct asset_global_settle_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; account_id_type issuer; ///< must equal @ref asset_to_settle->issuer asset_id_type asset_to_settle; @@ -575,8 +610,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } }; /** @@ -592,8 +625,18 @@ namespace graphene { namespace chain { * * The fee is paid by @ref account, and @ref account must authorize this operation */ - struct asset_settle_operation + struct asset_settle_operation : public base_operation { + struct fee_parameters_type { + /** this fee should be high to encourage small settlement requests to + * be performed on the market rather than via forced settlement. + * + * Note that in the event of a black swan or prediction market close out + * everyone will have to pay this fee. + */ + uint64_t fee = 100 * GRAPHENE_BLOCKCHAIN_PRECISION; + }; + asset fee; /// Account requesting the force settlement. This account pays the fee account_id_type account; @@ -602,19 +645,15 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust( fee_payer(), -fee ); - acc.adjust( account, -amount ); - } }; /** * @ingroup operations */ - struct asset_fund_fee_pool_operation + struct asset_fund_fee_pool_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; ///< core asset account_id_type from_account; asset_id_type asset_id; @@ -622,12 +661,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return from_account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - acc.adjust(fee_payer(), -amount); - } }; /** @@ -645,10 +678,17 @@ namespace graphene { namespace chain { * @pre @ref new_options SHALL be internally consistent, as verified by @ref validate() * @post @ref asset_to_update will have options matching those of new_options */ - struct asset_update_operation + struct asset_update_operation : public base_operation { + struct fee_parameters_type { + uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = 10; + }; + asset_update_operation(){} + /// Initializes the operation to apply changes to the provided asset, and copies old.options into @ref new_options + /// TODO: operations should not depend upon data model objects, reverse the dependency asset_update_operation(const asset_object& old); asset fee; @@ -657,12 +697,12 @@ namespace graphene { namespace chain { /// If the asset is to be given a new issuer, specify his ID here. optional new_issuer; + /// TODO: operations should not depend upon data model objects, reverse the dependency asset_object::asset_options new_options; account_id_type fee_payer()const { return issuer; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } + share_type calculate_fee(const fee_parameters_type& k)const; }; /** @@ -678,8 +718,10 @@ namespace graphene { namespace chain { * @pre @ref new_options SHALL be internally consistent, as verified by @ref validate() * @post @ref asset_to_update will have BitAsset-specific options matching those of new_options */ - struct asset_update_bitasset_operation + struct asset_update_bitasset_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; account_id_type issuer; asset_id_type asset_to_update; @@ -688,8 +730,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } }; /** @@ -708,8 +748,10 @@ namespace graphene { namespace chain { * @post All valid feeds supplied by feed producers in @ref new_feed_producers, which were already feed producers * prior to execution of this operation, will be preserved */ - struct asset_update_feed_producers_operation + struct asset_update_feed_producers_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 500 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; account_id_type issuer; asset_id_type asset_to_update; @@ -718,9 +760,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { acc.adjust(fee_payer(), -fee); } }; /** @@ -739,24 +778,29 @@ namespace graphene { namespace chain { * settlement price may be flipped either direction, as long as it is a ratio between the market-issued asset and * its collateral. */ - struct asset_publish_feed_operation + struct asset_publish_feed_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; ///< paid for by publisher account_id_type publisher; asset_id_type asset_id; ///< asset for which the feed is published price_feed feed; account_id_type fee_payer()const { return publisher; } - void validate()const; - share_type calculate_fee( const fee_schedule_type& k )const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } + void validate()const; }; /** * @ingroup operations */ - struct asset_issue_operation + struct asset_issue_operation : public base_operation { + struct fee_parameters_type { + uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = GRAPHENE_BLOCKCHAIN_PRECISION; + }; + asset fee; account_id_type issuer; ///< Must be asset_to_issue->asset_id->issuer asset asset_to_issue; @@ -768,9 +812,7 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return issuer; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { acc.adjust(fee_payer(), -fee); acc.adjust(issue_to_account, asset_to_issue); } + share_type calculate_fee(const fee_parameters_type& k)const; }; /** @@ -779,20 +821,16 @@ namespace graphene { namespace chain { * * @note You cannot burn market-issued assets. */ - struct asset_reserve_operation + struct asset_reserve_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; account_id_type payer; asset amount_to_reserve; account_id_type fee_payer()const { return payer; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - acc.adjust(fee_payer(), -amount_to_reserve); - } }; /** @@ -813,8 +851,10 @@ namespace graphene { namespace chain { * Market orders are matched in the order they are included * in the block chain. */ - struct limit_order_create_operation + struct limit_order_create_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 5 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; account_id_type seller; asset amount_to_sell; @@ -835,13 +875,7 @@ namespace graphene { namespace chain { } account_id_type fee_payer()const { return seller; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; price get_price()const { return amount_to_sell / min_to_receive; } - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - acc.adjust(seller, -amount_to_sell); - } }; @@ -852,8 +886,10 @@ namespace graphene { namespace chain { * * @return the amount actually refunded */ - struct limit_order_cancel_operation + struct limit_order_cancel_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 0; }; + asset fee; limit_order_id_type order; /** must be order->seller */ @@ -861,12 +897,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return fee_paying_account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - acc.adjust(fee_payer(), result.get()); - } }; @@ -882,22 +912,18 @@ namespace graphene { namespace chain { * * @note this operation can be used to force a market order using the collateral without requiring outside funds. */ - struct call_order_update_operation + struct call_order_update_operation : public base_operation { - asset fee; ///< paid by funding_account + /** this is slightly more expensive than limit orders, this pricing impacts prediction markets */ + struct fee_parameters_type { uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; }; + + asset fee; account_id_type funding_account; ///< pays fee, collateral, and cover asset delta_collateral; ///< the amount of collateral to add to the margin position asset delta_debt; ///< the amount of the debt to be paid off, may be negative to issue new debt account_id_type fee_payer()const { return funding_account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - acc.adjust(funding_account, -delta_collateral); - acc.adjust(funding_account, delta_debt); - } }; /** @@ -941,10 +967,15 @@ namespace graphene { namespace chain { * expiration_time cannot be farther in the future than the maximum expiration time set in the global properties * object. */ - struct proposal_create_operation + struct proposal_create_operation : public base_operation { - account_id_type fee_paying_account; + struct fee_parameters_type { + uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = 10; + }; + asset fee; + account_id_type fee_paying_account; vector proposed_ops; time_point_sec expiration_time; optional review_period_seconds; @@ -954,10 +985,8 @@ namespace graphene { namespace chain { static proposal_create_operation genesis_proposal(const class database& db); account_id_type fee_payer()const { return fee_paying_account; } - void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { acc.adjust(fee_payer(), -fee); } + void validate()const; + share_type calculate_fee(const fee_parameters_type& k)const; }; /** @@ -978,8 +1007,13 @@ namespace graphene { namespace chain { * If an account's owner and active authority are both required, only the owner authority may approve. An attempt to * add or remove active authority approval to such a proposal will fail. */ - struct proposal_update_operation + struct proposal_update_operation : public base_operation { + struct fee_parameters_type { + uint64_t fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = 10; + }; + account_id_type fee_paying_account; asset fee; proposal_id_type proposal; @@ -991,9 +1025,8 @@ namespace graphene { namespace chain { flat_set key_approvals_to_remove; account_id_type fee_payer()const { return fee_paying_account; } - void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } + void validate()const; + share_type calculate_fee(const fee_parameters_type& k)const; }; /** @@ -1007,8 +1040,10 @@ namespace graphene { namespace chain { * proposal expires. Using this operation, he can prevent any further breath from being wasted on such an absurd * proposal. */ - struct proposal_delete_operation + struct proposal_delete_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + account_id_type fee_paying_account; bool using_owner_authority = false; asset fee; @@ -1016,8 +1051,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return fee_paying_account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } }; ///@} @@ -1028,8 +1061,10 @@ namespace graphene { namespace chain { * emitted for the purpose of accurately tracking account history, accelerating * a reindex. */ - struct fill_order_operation + struct fill_order_operation : public base_operation { + struct fee_parameters_type {}; + object_id_type order_id; account_id_type account_id; asset pays; @@ -1045,13 +1080,9 @@ namespace graphene { namespace chain { } account_id_type fee_payer()const { return account_id; } void validate()const { FC_ASSERT( !"virtual operation" ); } - share_type calculate_fee(const fee_schedule_type& k)const - // This is a virtual operation; there is no fee - { return 0; } - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { - acc.adjust(account_id, receives); - } + /// This is a virtual operation; there is no fee + share_type calculate_fee(const fee_parameters_type& k)const { return 0; } }; /** @@ -1073,8 +1104,10 @@ namespace graphene { namespace chain { * The fee for this operation is paid by withdraw_from_account, and this account is required to authorize this * operation. */ - struct withdraw_permission_create_operation + struct withdraw_permission_create_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; /// The account authorizing withdrawals from its balances account_id_type withdraw_from_account; @@ -1091,8 +1124,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return withdraw_from_account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } }; /** @@ -1106,8 +1137,10 @@ namespace graphene { namespace chain { * * Fee is paid by withdraw_from_account, which is required to authorize this operation */ - struct withdraw_permission_update_operation + struct withdraw_permission_update_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; /// This account pays the fee. Must match permission_to_update->withdraw_from_account account_id_type withdraw_from_account; @@ -1126,8 +1159,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return withdraw_from_account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const { acc.adjust(fee_payer(), -fee); } }; /** @@ -1143,8 +1174,13 @@ namespace graphene { namespace chain { * * Fee is paid by withdraw_to_account, which is required to authorize this operation */ - struct withdraw_permission_claim_operation + struct withdraw_permission_claim_operation : public base_operation { + struct fee_parameters_type { + uint64_t fee = 20*GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = 10; + }; + /// Paid by withdraw_to_account asset fee; /// ID of the permission authorizing this withdrawal @@ -1160,13 +1196,7 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return withdraw_to_account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - acc.adjust(withdraw_to_account, amount_to_withdraw); - acc.adjust(withdraw_from_account, -amount_to_withdraw); - } + share_type calculate_fee(const fee_parameters_type& k)const; }; /** @@ -1177,8 +1207,10 @@ namespace graphene { namespace chain { * * Fee is paid by withdraw_from_account, which is required to authorize this operation */ - struct withdraw_permission_delete_operation + struct withdraw_permission_delete_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 0; }; + asset fee; /// Must match withdrawal_permission->withdraw_from_account. This account pays the fee. account_id_type withdraw_from_account; @@ -1189,11 +1221,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return withdraw_from_account; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - } }; struct linear_vesting_policy_initializer @@ -1231,8 +1258,10 @@ namespace graphene { namespace chain { * * @return ID of newly created vesting_balance_object */ - struct vesting_balance_create_operation + struct vesting_balance_create_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; account_id_type creator; ///< Who provides funds initially account_id_type owner; ///< Who is able to withdraw the balance @@ -1241,12 +1270,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return creator; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - acc.adjust(creator, -amount); - } }; @@ -1259,8 +1282,10 @@ namespace graphene { namespace chain { * * @return Nothing */ - struct vesting_balance_withdraw_operation + struct vesting_balance_withdraw_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 20*GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; vesting_balance_id_type vesting_balance; account_id_type owner; ///< Must be vesting_balance.owner @@ -1268,12 +1293,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return owner; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - acc.adjust(owner, amount); - } }; /** @@ -1303,8 +1322,10 @@ namespace graphene { namespace chain { * @brief Create a new worker object * @ingroup operations */ - struct worker_create_operation + struct worker_create_operation : public base_operation { + struct fee_parameters_type { uint64_t fee = 5000*GRAPHENE_BLOCKCHAIN_PRECISION; }; + asset fee; account_id_type owner; time_point_sec work_begin_date; @@ -1317,12 +1338,6 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return owner; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - } - }; ///@} @@ -1333,8 +1348,13 @@ namespace graphene { namespace chain { * There is no validation for this operation other than that required auths are valid and a fee * is paid that is appropriate for the data contained. */ - struct custom_operation + struct custom_operation : public base_operation { + struct fee_parameters_type { + uint64_t fee = GRAPHENE_BLOCKCHAIN_PRECISION; + uint32_t price_per_kbyte = 10; + }; + asset fee; account_id_type payer; flat_set required_auths; @@ -1343,11 +1363,7 @@ namespace graphene { namespace chain { account_id_type fee_payer()const { return payer; } void validate()const; - share_type calculate_fee(const fee_schedule_type& k)const; - void get_balance_delta(balance_accumulator& acc, const operation_result& result = asset())const - { - acc.adjust(fee_payer(), -fee); - } + share_type calculate_fee(const fee_parameters_type& k)const; }; /** @@ -1398,7 +1414,6 @@ namespace graphene { namespace chain { /// @} // operations group - /** * Appends required authorites to the result vector. The authorities appended are not the * same as those returned by get_required_auth @@ -1422,77 +1437,18 @@ namespace graphene { namespace chain { uint16_t op_num; }; - - /** - * @brief Used to calculate fees in a polymorphic manner - * - * If you wish to pay fees in an asset other than CORE, use the core_exchange_rate argument to specify the rate of - - * exchange rate. It is up to the caller to ensure that the core_exchange_rate converts to an asset accepted by the - * delegates at a rate which they will accept. - */ - struct operation_calculate_fee - { - const fee_schedule_type& fees; - const price& core_exchange_rate; - operation_calculate_fee( const fee_schedule_type& f, const price& core_exchange_rate = price::unit_price() ) - : fees(f), - core_exchange_rate(core_exchange_rate) - {} - typedef share_type result_type; - template - share_type operator()( const T& v )const { return (v.calculate_fee(fees) * core_exchange_rate).amount; } - }; - - /** - * @brief Used to set fees in a polymorphic manner - * - * If you wish to pay fees in an asset other than CORE, use the core_exchange_rate argument to specify the rate of - * conversion you wish to use. The operation's fee will be set by multiplying the CORE fee by the provided exchange - * rate. It is up to the caller to ensure that the core_exchange_rate converts to an asset accepted by the delegates - * at a rate which they will accept. - * - * If total_fee is not nullptr, the total fee for all operations visited will be stored in the provided share_type. - * The share_type will be set to zero when the visitor is constructed. - */ - struct operation_set_fee - { - const fee_schedule_type& fees; - const price& core_exchange_rate; - share_type* total_fee; - operation_set_fee( const fee_schedule_type& f, - const price& core_exchange_rate = price::unit_price(), - share_type* total_fee = nullptr ) - : fees(f), - core_exchange_rate(core_exchange_rate), - total_fee(total_fee) - { - if( total_fee ) - *total_fee = 0; - } - typedef asset result_type; - template - asset operator()( T& v )const { - asset fee = (v.calculate_fee(fees)) * core_exchange_rate; - if( total_fee ) *total_fee += fee.amount; - return v.fee = fee; - } - }; - /** * @brief necessary to support nested operations inside the proposal_create_operation */ struct op_wrapper { public: - op_wrapper(const operation& op = operation()):op(op){} - operation op; - void validate()const; - asset set_fee( const fee_schedule_type& k ) { return op.visit( operation_set_fee( k ) ); } - share_type calculate_fee( const fee_schedule_type& k )const { return op.visit( operation_calculate_fee( k ) ); } + op_wrapper(const operation& op = operation()):op(op){} + operation op; }; } } // graphene::chain + FC_REFLECT( graphene::chain::op_wrapper, (op) ) FC_REFLECT( graphene::chain::memo_message, (checksum)(text) ) FC_REFLECT( graphene::chain::memo_data, (from)(to)(nonce)(message) ) @@ -1503,12 +1459,54 @@ FC_REFLECT( graphene::chain::account_create_operation, (name)(owner)(active)(options) ) +FC_REFLECT( graphene::chain::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::account_whitelist_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::account_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) ) +FC_REFLECT( graphene::chain::account_transfer_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::delegate_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::witness_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::witness_withdraw_pay_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::global_parameters_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::transfer_operation::fee_parameters_type, (base_fee)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::override_transfer_operation::fee_parameters_type, (base_fee)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::asset_create_operation::fee_parameters_type, (symbol3)(symbol4)(long_symbol)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::asset_global_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::asset_settle_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::asset_fund_fee_pool_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::asset_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::asset_update_bitasset_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::asset_update_feed_producers_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::asset_publish_feed_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::asset_issue_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::asset_reserve_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::limit_order_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::limit_order_cancel_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::call_order_update_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::proposal_create_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::proposal_update_operation::fee_parameters_type, (fee)(price_per_kbyte) ) +FC_REFLECT( graphene::chain::proposal_delete_operation::fee_parameters_type, (fee) ) +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) ) +FC_REFLECT( graphene::chain::withdraw_permission_delete_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::vesting_balance_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::worker_create_operation::fee_parameters_type, (fee) ) +FC_REFLECT( graphene::chain::custom_operation::fee_parameters_type, (fee)(price_per_kbyte) ) + +/// THIS IS THE ONLY VIRTUAL OPERATION THUS FAR... +FC_REFLECT( graphene::chain::fill_order_operation::fee_parameters_type, ) + FC_REFLECT( graphene::chain::account_update_operation, (fee)(account)(owner)(active)(new_options) ) -FC_REFLECT( graphene::chain::account_upgrade_operation, (fee)(account_to_upgrade)(upgrade_to_lifetime_member) ) + +FC_REFLECT( graphene::chain::account_upgrade_operation, + (fee)(account_to_upgrade)(upgrade_to_lifetime_member) ) FC_REFLECT_TYPENAME( graphene::chain::account_whitelist_operation::account_listing) + FC_REFLECT_ENUM( graphene::chain::account_whitelist_operation::account_listing, (no_listing)(white_listed)(black_listed)(white_and_black_listed)) @@ -1599,9 +1597,12 @@ FC_REFLECT( graphene::chain::void_result, ) FC_REFLECT( graphene::chain::balance_claim_operation, (fee)(deposit_to_account)(balance_to_claim)(balance_owner_key)(total_claimed) ) +FC_REFLECT(graphene::chain::account_options, (memo_key)(voting_account)(num_witness)(num_committee)(votes)) + FC_REFLECT_TYPENAME( graphene::chain::operation ) FC_REFLECT_TYPENAME( graphene::chain::operation_result ) FC_REFLECT_TYPENAME( fc::flat_set ) FC_REFLECT(graphene::chain::linear_vesting_policy_initializer, (begin_timestamp)(vesting_cliff_seconds)(vesting_duration_seconds) ) FC_REFLECT(graphene::chain::cdd_vesting_policy_initializer, (start_claim)(vesting_seconds) ) FC_REFLECT_TYPENAME( graphene::chain::vesting_policy_initializer ) + diff --git a/libraries/chain/include/graphene/chain/types.hpp b/libraries/chain/include/graphene/chain/types.hpp index f0bbe79d..d391f19e 100644 --- a/libraries/chain/include/graphene/chain/types.hpp +++ b/libraries/chain/include/graphene/chain/types.hpp @@ -143,6 +143,8 @@ namespace graphene { namespace chain { meta_account_object_type }; + struct chain_parameters; + //typedef fc::unsigned_int object_id_type; //typedef uint64_t object_id_type; @@ -311,112 +313,6 @@ namespace graphene { namespace chain { } }; - struct fee_schedule_type - { - /// The number of bytes to charge a data fee for - const static int BYTES_PER_DATA_FEE = 1024; - - template - uint32_t total_data_fee(Ts... ts)const { - return data_size(ts...) / BYTES_PER_DATA_FEE * data_fee; - // return ((fc::uint128(data_size(ts...)) * data_fee) / BYTES_PER_DATA_FEE).to_uint64(); - } - - - - /** - * Standard fees - * - * These fees are listed because they will be updated frequently and it is lower - * overhead than having a key/value map. - */ - ///@{ - uint64_t key_create_fee = 270300; ///< the cost to register a public key with the blockchain - uint64_t account_create_fee = 666666; ///< the cost to register the cheapest non-free account - uint64_t account_update_fee = 150000; ///< the cost to update an existing account - uint64_t account_transfer_fee = 300000; ///< the cost to transfer an account to a new owner - uint64_t account_whitelist_fee = 300000; ///< the fee to whitelist an account - uint64_t account_len8up_fee = 5*10000000; ///< about $1 - uint64_t account_len7_fee = 5*100000000; ///< about $10 - uint64_t account_len6_fee = 5*UINT64_C(500000000); ///< about $50 - uint64_t account_len5_fee = 5*UINT64_C(1000000000); ///< about $100 - uint64_t account_len4_fee = 5*UINT64_C(2000000000); ///< about $200 - uint64_t account_len3_fee = 5*UINT64_C(3000000000); ///< about $300 - uint64_t account_len2_fee = 5*UINT64_C(4000000000); ///< about $400 - uint64_t asset_create_fee = 5*UINT64_C(500000000); ///< about $35 for LTM, the cost to register the cheapest asset - uint64_t asset_update_fee = 150000; ///< the cost to modify a registered asset - uint64_t asset_issue_fee = 700000; ///< the cost to print a UIA and send it to an account - uint64_t asset_reserve_fee = 1500000; ///< the cost to return an asset to the reserve pool - uint64_t asset_fund_fee_pool_fee = 150000; ///< the cost to add funds to an asset's fee pool - uint64_t asset_settle_fee = 7000000; ///< the cost to trigger a forced settlement of a market-issued asset - uint64_t asset_global_settle_fee = 140000000; ///< the cost to trigger a global forced settlement of a market asset - uint64_t asset_len7up_fee = 5*UINT64_C(500000000); ///< about $35 for LTM - uint64_t asset_len6_fee = 5*5000000000; ///< about $350 for LTM - uint64_t asset_len5_fee = 5*10000000000; ///< about $700 for LTM - uint64_t asset_len4_fee = 5*50000000000; ///< about $3500 for LTM - uint64_t asset_len3_fee = 5*70000000000; ///< about $5000 for LTM - uint64_t delegate_create_fee = 680000000; ///< fee for registering as a delegate; used to discourage frivolous delegates - uint64_t witness_create_fee = 680000000; /// < fee for registering as a witness - uint64_t witness_withdraw_pay_fee = 1500000; ///< fee for withdrawing witness pay - uint64_t transfer_fee = 2700000; ///< fee for transferring some asset - uint64_t limit_order_create_fee = 666666; ///< fee for placing a limit order in the markets - uint64_t call_order_fee = 800000; ///< fee for placing a call order in the markets - uint64_t publish_feed_fee = 10000; ///< fee for publishing a price feed - uint64_t data_fee = 13500000; ///< a price per BYTES_PER_DATA_FEE bytes of user data - uint64_t global_parameters_update_fee = 1350000; ///< the cost to update the global parameters - uint64_t membership_annual_fee = 270000000; ///< the annual cost of a membership subscription - uint64_t membership_lifetime_fee = 1350000000; ///< the cost to upgrade to a lifetime member - uint64_t withdraw_permission_create_fee = 2700000; ///< the cost to create a withdraw permission - uint64_t withdraw_permission_update_fee = 150000; ///< the cost to update a withdraw permission - uint64_t withdraw_permission_claim_fee = 700000; ///< the cost to withdraw from a withdraw permission - uint64_t vesting_balance_create_fee = 7000000; - uint64_t vesting_balance_withdraw_fee = 2700000; - uint64_t worker_create_fee = 680000000; ///< the cost to create a new worker - uint64_t assert_op_fee = 150000; ///< fee per assert operation - uint64_t proposal_create_fee = 7000000; ///< fee for creating a proposed transaction - uint64_t proposal_update_fee = 1500000; ///< fee for adding or removing approval of a proposed transaction - uint64_t custom_operation_fee = 300000; ///< fee for a custom operation - ///@{ - - void set_all_fees( uint64_t v ); - - /** Advanced Fees - * - * THese fields are reserved for future expansion of the fee schedule without breaking the - * protocol serialization. - */ - ///@{ - enum extended_fee_id - { - withdraw_permission_delete_fee_id = 1, ///< the cost to delete a withdraw permission - proposal_delete_fee_id = 2, ///< fee for deleting a proposed transaction - limit_order_cancel_fee_id = 3 ///< fee for canceling a limit order - }; - - uint64_t get_extended_fee( extended_fee_id id )const - { - auto itr = extended.find(id); - if( itr == extended.end() ) return 0; - return itr->second; - } - - uint64_t withdraw_permission_delete_fee()const { return get_extended_fee( withdraw_permission_delete_fee_id ); } - - - flat_map extended; - ///@} - - protected: - uint64_t data_size()const { - return 0; - } - template - uint64_t data_size(T t, Ts... ts)const { - return fc::raw::pack_size(t) + data_size(ts...); - } - }; - - struct public_key_type { struct binary_key @@ -443,68 +339,6 @@ namespace graphene { namespace chain { bool is_valid_v1( const std::string& base58str ); }; - typedef static_variant<> parameter_extension; - - struct chain_parameters - { - fee_schedule_type current_fees; ///< current schedule of fees - uint8_t block_interval = GRAPHENE_DEFAULT_BLOCK_INTERVAL; ///< interval in seconds between blocks - uint32_t maintenance_interval = GRAPHENE_DEFAULT_MAINTENANCE_INTERVAL; ///< interval in sections between blockchain maintenance events - uint32_t genesis_proposal_review_period = GRAPHENE_DEFAULT_GENESIS_PROPOSAL_REVIEW_PERIOD_SEC; ///< minimum time in seconds that a proposed transaction requiring genesis authority may not be signed, prior to expiration - uint32_t maximum_transaction_size = GRAPHENE_DEFAULT_MAX_TRANSACTION_SIZE; ///< maximum allowable size in bytes for a transaction - uint32_t maximum_block_size = GRAPHENE_DEFAULT_MAX_BLOCK_SIZE; ///< maximum allowable size in bytes for a block - uint32_t maximum_undo_history = GRAPHENE_DEFAULT_MAX_UNDO_HISTORY; ///< maximum number of undo states to keep in RAM - uint32_t maximum_time_until_expiration = GRAPHENE_DEFAULT_MAX_TIME_UNTIL_EXPIRATION; ///< maximum lifetime in seconds for transactions to be valid, before expiring - uint32_t maximum_proposal_lifetime = GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC; ///< maximum lifetime in seconds for proposed transactions to be kept, before expiring - uint8_t maximum_asset_whitelist_authorities = GRAPHENE_DEFAULT_MAX_ASSET_WHITELIST_AUTHORITIES; ///< maximum number of accounts which an asset may list as authorities for its whitelist OR blacklist - uint8_t maximum_asset_feed_publishers = GRAPHENE_DEFAULT_MAX_ASSET_FEED_PUBLISHERS; ///< the maximum number of feed publishers for a given asset - uint16_t maximum_witness_count = GRAPHENE_DEFAULT_MAX_WITNESSES; ///< maximum number of active witnesses - uint16_t maximum_committee_count = GRAPHENE_DEFAULT_MAX_COMMITTEE; ///< maximum number of active delegates - uint16_t maximum_authority_membership = GRAPHENE_DEFAULT_MAX_AUTHORITY_MEMBERSHIP; ///< largest number of keys/accounts an authority can have - uint16_t reserve_percent_of_fee = GRAPHENE_DEFAULT_BURN_PERCENT_OF_FEE; ///< the percentage of the network's allocation of a fee that is taken out of circulation - uint16_t network_percent_of_fee = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE; ///< percent of transaction fees paid to network - uint16_t lifetime_referrer_percent_of_fee = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE; ///< percent of transaction fees paid to network - uint32_t cashback_vesting_period_seconds = GRAPHENE_DEFAULT_CASHBACK_VESTING_PERIOD_SEC; ///< time after cashback rewards are accrued before they become liquid - share_type cashback_vesting_threshold = GRAPHENE_DEFAULT_CASHBACK_VESTING_THRESHOLD; ///< the maximum cashback that can be received without vesting - uint16_t max_bulk_discount_percent_of_fee = GRAPHENE_DEFAULT_MAX_BULK_DISCOUNT_PERCENT; ///< the maximum percentage discount for bulk discounts - share_type bulk_discount_threshold_min = GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MIN; ///< the minimum amount of fees paid to qualify for bulk discounts - share_type bulk_discount_threshold_max = GRAPHENE_DEFAULT_BULK_DISCOUNT_THRESHOLD_MAX; ///< the amount of fees paid to qualify for the max bulk discount percent - bool count_non_member_votes = true; ///< set to false to restrict voting privlegages to member accounts - bool allow_non_member_whitelists = false; ///< true if non-member accounts may set whitelists and blacklists; false otherwise - share_type witness_pay_per_block = GRAPHENE_DEFAULT_WITNESS_PAY_PER_BLOCK; ///< CORE to be allocated to witnesses (per block) - share_type worker_budget_per_day = GRAPHENE_DEFAULT_WORKER_BUDGET_PER_DAY; ///< CORE to be allocated to workers (per day) - uint16_t max_predicate_opcode = GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE; ///< predicate_opcode must be less than this number - share_type fee_liquidation_threshold = GRAPHENE_DEFAULT_FEE_LIQUIDATION_THRESHOLD; ///< value in CORE at which accumulated fees in blockchain-issued market assets should be liquidated - uint16_t accounts_per_fee_scale = GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE; ///< number of accounts between fee scalings - uint8_t account_fee_scale_bitshifts = GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS; ///< number of times to left bitshift account registration fee at each scaling - vector extensions; - - void validate()const - { - FC_ASSERT( reserve_percent_of_fee <= GRAPHENE_100_PERCENT ); - FC_ASSERT( network_percent_of_fee <= GRAPHENE_100_PERCENT ); - FC_ASSERT( max_bulk_discount_percent_of_fee <= GRAPHENE_100_PERCENT ); - FC_ASSERT( lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT ); - FC_ASSERT( network_percent_of_fee + lifetime_referrer_percent_of_fee <= GRAPHENE_100_PERCENT ); - FC_ASSERT( bulk_discount_threshold_min <= bulk_discount_threshold_max ); - FC_ASSERT( bulk_discount_threshold_min > 0 ); - - FC_ASSERT( block_interval <= GRAPHENE_MAX_BLOCK_INTERVAL ); - FC_ASSERT( block_interval > 0 ); - FC_ASSERT( maintenance_interval > block_interval, - "Maintenance interval must be longer than block interval" ); - FC_ASSERT( maintenance_interval % block_interval == 0, - "Maintenance interval must be a multiple of block interval" ); - FC_ASSERT( maximum_transaction_size >= GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT, - "Transaction size limit is too low" ); - FC_ASSERT( maximum_block_size >= GRAPHENE_MIN_BLOCK_SIZE_LIMIT, - "Block size limit is too low" ); - FC_ASSERT( maximum_time_until_expiration > block_interval, - "Maximum transaction expiration time must be greater than a block interval" ); - FC_ASSERT( maximum_proposal_lifetime - genesis_proposal_review_period > block_interval, - "Genesis proposal review period must be less than the maximum proposal lifetime" ); - } - }; } } // graphene::chain @@ -561,92 +395,6 @@ FC_REFLECT_ENUM( graphene::chain::impl_object_type, FC_REFLECT_ENUM( graphene::chain::meta_info_object_type, (meta_account_object_type)(meta_asset_object_type) ) -FC_REFLECT( graphene::chain::fee_schedule_type, - (key_create_fee) - (account_create_fee) - (account_update_fee) - (account_transfer_fee) - (account_len8up_fee) - (account_len7_fee) - (account_len6_fee) - (account_len5_fee) - (account_len4_fee) - (account_len3_fee) - (account_len2_fee) - (asset_len3_fee) - (asset_len4_fee) - (asset_len5_fee) - (asset_len6_fee) - (asset_len7up_fee) - (account_whitelist_fee) - (delegate_create_fee) - (witness_create_fee) - (witness_withdraw_pay_fee) - (transfer_fee) - (limit_order_create_fee) - (call_order_fee) - (publish_feed_fee) - (asset_create_fee) - (asset_update_fee) - (asset_issue_fee) - (asset_reserve_fee) - (asset_fund_fee_pool_fee) - (asset_settle_fee) - (data_fee) - (global_parameters_update_fee) - (membership_annual_fee) - (membership_lifetime_fee) - (withdraw_permission_create_fee) - (withdraw_permission_update_fee) - (withdraw_permission_claim_fee) - (vesting_balance_create_fee) - (vesting_balance_withdraw_fee) - (asset_global_settle_fee) - (worker_create_fee) - (assert_op_fee) - (proposal_create_fee) - (proposal_update_fee) - (extended) - ) -FC_REFLECT_ENUM( graphene::chain::fee_schedule_type::extended_fee_id, - (withdraw_permission_delete_fee_id) - (proposal_delete_fee_id) - (limit_order_cancel_fee_id) ) - -FC_REFLECT( graphene::chain::chain_parameters, - (current_fees) - (block_interval) - (maintenance_interval) - (genesis_proposal_review_period) - (maximum_transaction_size) - (maximum_block_size) - (maximum_undo_history) - (maximum_time_until_expiration) - (maximum_proposal_lifetime) - (maximum_asset_whitelist_authorities) - (maximum_asset_feed_publishers) - (maximum_witness_count) - (maximum_committee_count) - (maximum_authority_membership) - (reserve_percent_of_fee) - (network_percent_of_fee) - (lifetime_referrer_percent_of_fee) - (max_bulk_discount_percent_of_fee) - (cashback_vesting_period_seconds) - (cashback_vesting_threshold) - (bulk_discount_threshold_min) - (bulk_discount_threshold_max) - (count_non_member_votes) - (allow_non_member_whitelists) - (witness_pay_per_block) - (worker_budget_per_day) - (max_predicate_opcode) - (fee_liquidation_threshold) - (accounts_per_fee_scale) - (account_fee_scale_bitshifts) - (extensions) - ) - FC_REFLECT_TYPENAME( graphene::chain::share_type ) FC_REFLECT_TYPENAME( graphene::chain::account_id_type ) diff --git a/libraries/chain/types.cpp b/libraries/chain/types.cpp index b0fe691c..bef1bba1 100644 --- a/libraries/chain/types.cpp +++ b/libraries/chain/types.cpp @@ -105,35 +105,6 @@ namespace graphene { namespace chain { { return p1.key_data != p2.key_data; } - /** - * @brief The fee_set_visitor struct sets all fees to a particular value in one fell swoop - * - * Example: - * @code - * fee_schedule_type sch; - * // Set all fees to 50 - * fc::reflector::visit(fee_schedule_type::fee_set_visitor{sch, 50}); - * @endcode - */ - struct fee_set_visitor { - fee_schedule_type& f; - uint64_t fee; - - template - void operator()(const char*)const - { - f.*member = fee; - } - template (Class::*member)> - void operator()(const char*)const - { - } - }; - - void fee_schedule_type::set_all_fees( uint64_t v ) - { - fc::reflector::visit(fee_set_visitor{*this, v}); - } } } // graphene::chain