From e008cbb70b52b859b2cf55373ab9ff257a133fdd Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Thu, 17 Sep 2015 13:45:12 -0400 Subject: [PATCH 1/2] database_api.cpp: Include smart_ref_impl, fix #321 --- libraries/app/database_api.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/app/database_api.cpp b/libraries/app/database_api.cpp index cebfdc89..67717855 100644 --- a/libraries/app/database_api.cpp +++ b/libraries/app/database_api.cpp @@ -2,6 +2,7 @@ #include #include +#include #include From f0502ee2f15bdbcf81203f8859983817c23cd2cf Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Thu, 17 Sep 2015 15:12:08 -0400 Subject: [PATCH 2/2] Implement virtual op for settlement cancel #250 --- libraries/app/impacted.cpp | 11 +++++++- libraries/chain/db_market.cpp | 11 ++++++-- .../graphene/chain/protocol/asset_ops.hpp | 25 +++++++++++++++++++ .../graphene/chain/protocol/operations.hpp | 6 +++-- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/libraries/app/impacted.cpp b/libraries/app/impacted.cpp index c0674621..a0c73999 100644 --- a/libraries/app/impacted.cpp +++ b/libraries/app/impacted.cpp @@ -37,7 +37,10 @@ struct get_impacted_account_visitor } void operator()( const limit_order_create_operation& op ) {} - void operator()( const limit_order_cancel_operation& op ) {} + void operator()( const limit_order_cancel_operation& op ) + { + _impacted.insert( op.fee_paying_account ); + } void operator()( const call_order_update_operation& op ) {} void operator()( const fill_order_operation& op ) { @@ -182,6 +185,12 @@ struct get_impacted_account_visitor for( const auto& in : op.inputs ) add_authority_accounts( _impacted, in.owner ); } + + void operator()( const asset_settle_cancel_operation& op ) + { + _impacted.insert( op.account ); + } + }; void operation_get_impacted_accounts( const operation& op, flat_set& result ) diff --git a/libraries/chain/db_market.cpp b/libraries/chain/db_market.cpp index 8b20c3c9..54fa666a 100644 --- a/libraries/chain/db_market.cpp +++ b/libraries/chain/db_market.cpp @@ -93,7 +93,11 @@ void database::cancel_order(const force_settlement_object& order, bool create_vi if( create_virtual_op ) { - // TODO: create virtual op + asset_settle_cancel_operation vop; + vop.settlement = order.id; + vop.account = order.owner; + vop.amount = order.balance; + push_applied_operation( vop ); } } @@ -109,7 +113,10 @@ void database::cancel_order( const limit_order_object& order, bool create_virtua if( create_virtual_op ) { - // TODO: create a virtual cancel operation + limit_order_cancel_operation vop; + vop.order = order.id; + vop.fee_paying_account = order.seller; + push_applied_operation( vop ); } remove(order); diff --git a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp index f79b3aec..4dec16e0 100644 --- a/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp +++ b/libraries/chain/include/graphene/chain/protocol/asset_ops.hpp @@ -189,6 +189,29 @@ namespace graphene { namespace chain { void validate()const; }; + /** + * Virtual op generated when force settlement is cancelled. + */ + + struct asset_settle_cancel_operation : public base_operation + { + struct fee_parameters_type { }; + + asset fee; + force_settlement_id_type settlement; + /// Account requesting the force settlement. This account pays the fee + account_id_type account; + /// Amount of asset to force settle. This must be a market-issued asset + asset amount; + extensions_type extensions; + + account_id_type fee_payer()const { return account; } + void validate()const {} + + share_type calculate_fee(const fee_parameters_type& params)const + { return 0; } + }; + /** * @ingroup operations */ @@ -407,6 +430,7 @@ FC_REFLECT( graphene::chain::bitasset_options, 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_settle_cancel_operation::fee_parameters_type, ) 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) ) @@ -447,6 +471,7 @@ FC_REFLECT( graphene::chain::asset_update_feed_producers_operation, FC_REFLECT( graphene::chain::asset_publish_feed_operation, (fee)(publisher)(asset_id)(feed)(extensions) ) FC_REFLECT( graphene::chain::asset_settle_operation, (fee)(account)(amount)(extensions) ) +FC_REFLECT( graphene::chain::asset_settle_cancel_operation, (fee)(settlement)(account)(amount)(extensions) ) FC_REFLECT( graphene::chain::asset_global_settle_operation, (fee)(issuer)(asset_to_settle)(settle_price)(extensions) ) FC_REFLECT( graphene::chain::asset_issue_operation, (fee)(issuer)(asset_to_issue)(issue_to_account)(memo)(extensions) ) diff --git a/libraries/chain/include/graphene/chain/protocol/operations.hpp b/libraries/chain/include/graphene/chain/protocol/operations.hpp index b60504bd..6d4afab6 100644 --- a/libraries/chain/include/graphene/chain/protocol/operations.hpp +++ b/libraries/chain/include/graphene/chain/protocol/operations.hpp @@ -28,7 +28,7 @@ namespace graphene { namespace chain { limit_order_create_operation, limit_order_cancel_operation, call_order_update_operation, - fill_order_operation, + fill_order_operation, // VIRTUAL account_create_operation, account_update_operation, account_whitelist_operation, @@ -65,7 +65,9 @@ namespace graphene { namespace chain { override_transfer_operation, transfer_to_blind_operation, blind_transfer_operation, - transfer_from_blind_operation + transfer_from_blind_operation, + + asset_settle_cancel_operation // VIRTUAL > operation; /// @} // operations group