Merge remote-tracking branch 'graphene/develop' into bitshares at commit e3478d2338
This commit is contained in:
commit
52c0b31bcf
9 changed files with 38 additions and 5 deletions
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
add_custom_target( build_hardfork_hpp
|
||||
COMMAND cat-parts hardfork.d "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" )
|
||||
COMMAND cat-parts "${CMAKE_CURRENT_SOURCE_DIR}/hardfork.d" "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" )
|
||||
set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp" PROPERTIES GENERATED TRUE )
|
||||
|
||||
add_dependencies( build_hardfork_hpp cat-parts )
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include <graphene/chain/witness_object.hpp>
|
||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||
#include <graphene/chain/exceptions.hpp>
|
||||
#include <graphene/chain/evaluator.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
|
|
|
|||
|
|
@ -118,4 +118,14 @@ database& generic_evaluator::db()const { return trx_state->db(); }
|
|||
_fba.accumulated_fba_fees += core_fee_paid;
|
||||
} );
|
||||
}
|
||||
|
||||
share_type generic_evaluator::calculate_fee_for_operation(const operation& op) const
|
||||
{
|
||||
return db().current_fee_schedule().calculate_fee( op ).amount;
|
||||
}
|
||||
void generic_evaluator::db_adjust_balance(const account_id_type& fee_payer, asset fee_from_account)
|
||||
{
|
||||
db().adjust_balance(fee_payer, fee_from_account);
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
* THE SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
#include <graphene/chain/evaluator.hpp>
|
||||
#include <graphene/chain/global_property_object.hpp>
|
||||
#include <graphene/chain/node_property_object.hpp>
|
||||
#include <graphene/chain/account_object.hpp>
|
||||
|
|
@ -30,6 +29,7 @@
|
|||
#include <graphene/chain/fork_database.hpp>
|
||||
#include <graphene/chain/block_database.hpp>
|
||||
#include <graphene/chain/genesis_state.hpp>
|
||||
#include <graphene/chain/evaluator.hpp>
|
||||
|
||||
#include <graphene/db/object_database.hpp>
|
||||
#include <graphene/db/object.hpp>
|
||||
|
|
@ -45,6 +45,8 @@
|
|||
namespace graphene { namespace chain {
|
||||
using graphene::db::abstract_object;
|
||||
using graphene::db::object;
|
||||
class op_evaluator;
|
||||
class transaction_evaluation_state;
|
||||
|
||||
struct budget_record;
|
||||
|
||||
|
|
|
|||
|
|
@ -102,6 +102,12 @@ namespace graphene { namespace chain {
|
|||
*/
|
||||
void pay_fba_fee( uint64_t fba_id );
|
||||
|
||||
// the next two functions are helpers that allow template functions declared in this
|
||||
// header to call db() without including database.hpp, which would
|
||||
// cause a circular dependency
|
||||
share_type calculate_fee_for_operation(const operation& op) const;
|
||||
void db_adjust_balance(const account_id_type& fee_payer, asset fee_from_account);
|
||||
|
||||
asset fee_from_account;
|
||||
share_type core_fee_paid;
|
||||
const account_object* fee_paying_account = nullptr;
|
||||
|
|
@ -143,10 +149,11 @@ namespace graphene { namespace chain {
|
|||
prepare_fee(op.fee_payer(), op.fee);
|
||||
if( !trx_state->skip_fee_schedule_check )
|
||||
{
|
||||
GRAPHENE_ASSERT( core_fee_paid >= db().current_fee_schedule().calculate_fee( op ).amount,
|
||||
share_type required_fee = calculate_fee_for_operation(op);
|
||||
GRAPHENE_ASSERT( core_fee_paid >= required_fee,
|
||||
insufficient_fee,
|
||||
"Insufficient Fee Paid",
|
||||
("core_fee_paid",core_fee_paid)("required",db().current_fee_schedule().calculate_fee( op ).amount) );
|
||||
("core_fee_paid",core_fee_paid)("required", required_fee) );
|
||||
}
|
||||
|
||||
return eval->do_evaluate(op);
|
||||
|
|
@ -162,7 +169,7 @@ namespace graphene { namespace chain {
|
|||
|
||||
auto result = eval->do_apply(op);
|
||||
|
||||
db().adjust_balance(op.fee_payer(), -fee_from_account);
|
||||
db_adjust_balance(op.fee_payer(), -fee_from_account);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ struct graphene_extension_unpack_visitor
|
|||
template< typename Stream, typename T >
|
||||
void operator>>( Stream& s, graphene::chain::extension<T>& value )
|
||||
{
|
||||
value = graphene::chain::extension<T>();
|
||||
graphene_extension_unpack_visitor<Stream, T> vtor( s, value.value );
|
||||
fc::reflector<T>::visit( vtor );
|
||||
FC_ASSERT( vtor.count_left == 0 ); // unrecognized extension throws here
|
||||
|
|
@ -168,6 +169,15 @@ struct graphene_extension_from_variant_visitor
|
|||
template< typename T >
|
||||
void from_variant( const fc::variant& var, graphene::chain::extension<T>& value )
|
||||
{
|
||||
value = graphene::chain::extension<T>();
|
||||
if( var.is_null() )
|
||||
return;
|
||||
if( var.is_array() )
|
||||
{
|
||||
FC_ASSERT( var.size() == 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
graphene_extension_from_variant_visitor<T> vtor( var.get_object(), value.value );
|
||||
fc::reflector<T>::visit( vtor );
|
||||
FC_ASSERT( vtor.count_left == 0 ); // unrecognized extension throws here
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include <algorithm>
|
||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||
#include <fc/smart_ref_impl.hpp>
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ int main( int argc, char** argv, char** envp )
|
|||
}
|
||||
|
||||
{
|
||||
boost::filesystem::create_directories(opath.parent_path());
|
||||
boost::filesystem::ofstream ofs(opath);
|
||||
ofs.write( new_data.c_str(), new_data.length() );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
#include <graphene/chain/fba_object.hpp>
|
||||
#include <graphene/chain/market_object.hpp>
|
||||
#include <graphene/chain/vesting_balance_object.hpp>
|
||||
#include <graphene/chain/exceptions.hpp>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue